Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- You can get this error if your abstract and concrete syntax are mismatched. Here's an example:
- ```haskell
- -- Abstract
- fun NP_sleeps_S : NP -> S ;
- -- Concrete
- lin NP_sleeps_S np = mkS (mkCl np sleep_V) ;
- ```
- Now I make a change in the abstract, but forget to update the concrete:
- ```haskell
- -- Abstract
- fun NP_sleeps_Utt : NP -> Utt ;
- -- Concrete
- lin NP_sleeps_Utt np = mkS (mkCl np sleep_V) ;
- ```
- I changed only the name in the concrete syntax, but not the right-hand side: it still starts with `mkS`. So I get this error:
- ```
- Happened in linearization of NP_sleeps_Utt
- no overload instance of mkS
- for
- {s : STense => Anteriority => Polarity => Order => Str;
- lock_Cl : {}}
- among
- {s : STense => Anteriority => Polarity => Order => Str;
- lock_Cl : {}}
- {s : Str; lock_Tense : {};
- t : STense} {s : STense => Anteriority => Polarity => Order => Str;
- lock_Cl : {}}
- …
- with value type Utt
- ```
- This error message is very long and verbose, so the hint "with value type Utt" is even harder to miss.
- But if you just squint really hard, you can see the error: *no overload instance of mkS `<lots of junk>` with value type Utt*.
- (Obviously this is not easy to see, otherwise I wouldn't be writing this post.)
- Now that we know what the error is, it's hard to pretend we have no idea, but in the real situation when this happens to you,
- it can often help to type annotate your expressions, even if you don't know if it helps. At least you might get a different error message:
- ```haskell
- -- Abstract
- fun NP_sleeps_Utt : NP -> Utt ;
- -- Concrete
- lin NP_sleeps_Utt np = <mkS (mkCl np sleep_V) : S> ;
- ```
- One thing is that once you write an explicit type annotation, "this RHS is supposed to be an S",
- you might notice the mismatch with the LHS, which says Utt.
- But suppose you don't notice it (maybe you never updated the name in the first place),
- let's see what is the new error message:
- ```
- Happened in linearization of NP_sleeps_Utt
- missing record fields: s type of TUseCl TPres ASimul PPos ((\s,v -> PredVP s (UseV v)) np sleep_V)
- expected: {s : Str}
- inferred: {s : CommonScand.Order => Str; lock_S : {}}
- ```
- Aside from the line `s type of TUseCl …`, which is a bit mysterious (what is T in TUseCl?), this error message is much nicer.
- The compile *expects* a `{s : Str}`, but is getting (*infers*) some other type instead.
- I would personally change "inferred" to "received" or "given", because that's what it means: *I wanted an Utt but you gave me an S*.
- The solution is just to update the concrete syntax:
- ```haskell
- -- Abstract
- fun NP_sleeps_Utt : NP -> Utt ;
- -- Concrete
- lin NP_sleeps_Utt np = mkUtt (mkS (mkCl np sleep_V)) ;
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement