SHARE
TWEET

Untitled

a guest May 24th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. You can get this error if your abstract and concrete syntax are mismatched. Here's an example:
  2.  
  3. ```haskell
  4. -- Abstract
  5. fun NP_sleeps_S : NP -> S ;
  6.  
  7. -- Concrete
  8. lin NP_sleeps_S np = mkS (mkCl np sleep_V) ;
  9. ```
  10.  
  11. Now I make a change in the abstract, but forget to update the concrete:
  12.  
  13.  
  14. ```haskell
  15. -- Abstract
  16. fun NP_sleeps_Utt : NP -> Utt ;
  17.  
  18. -- Concrete
  19. lin NP_sleeps_Utt np = mkS (mkCl np sleep_V) ;
  20. ```
  21.  
  22. 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:
  23.  
  24. ```
  25.     Happened in linearization of NP_sleeps_Utt
  26.       no overload instance of mkS
  27.       for
  28.         {s : STense => Anteriority => Polarity => Order => Str;
  29.          lock_Cl : {}}
  30.       among
  31.         {s : STense => Anteriority => Polarity => Order => Str;
  32.          lock_Cl : {}}
  33.         {s : Str; lock_Tense : {};
  34.           t : STense} {s : STense => Anteriority => Polarity => Order => Str;
  35.                        lock_Cl : {}}
  36.         …
  37.       with value type Utt
  38. ```
  39.  
  40. This error message is very long and verbose, so the hint "with value type Utt" is even harder to miss.
  41. But if you just squint really hard, you can see the error: *no overload instance of mkS `<lots of junk>` with value type Utt*.
  42.  
  43. (Obviously this is not easy to see, otherwise I wouldn't be writing this post.)
  44.  
  45. 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,
  46. 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:
  47.  
  48.  
  49. ```haskell
  50. -- Abstract
  51. fun NP_sleeps_Utt : NP -> Utt ;
  52.  
  53. -- Concrete
  54. lin NP_sleeps_Utt np = <mkS (mkCl np sleep_V) : S> ;
  55. ```
  56.  
  57. One thing is that once you write an explicit type annotation, "this RHS is supposed to be an S",
  58. you might notice the mismatch with the LHS, which says Utt.
  59. But suppose you don't notice it (maybe you never updated the name in the first place),
  60. let's see what is the new error message:
  61.  
  62. ```
  63.      Happened in linearization of NP_sleeps_Utt
  64.       missing record fields: s type of TUseCl TPres ASimul PPos ((\s,v -> PredVP s (UseV v)) np sleep_V)
  65.       expected: {s : Str}
  66.       inferred: {s : CommonScand.Order => Str; lock_S : {}}
  67. ```
  68.  
  69. Aside from the line `s type of TUseCl …`, which is a bit mysterious (what is T in TUseCl?), this error message is much nicer.
  70. The compile *expects* a `{s : Str}`, but is getting (*infers*) some other type instead.
  71. 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*.
  72.  
  73.  
  74. The solution is just to update the concrete syntax:
  75.  
  76. ```haskell
  77. -- Abstract
  78. fun NP_sleeps_Utt : NP -> Utt ;
  79.  
  80. -- Concrete
  81. lin NP_sleeps_Utt np = mkUtt (mkS (mkCl np sleep_V)) ;
  82. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top