Advertisement
Guest User

Untitled

a guest
May 24th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  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. with value type Utt
  37. ```
  38.  
  39. This error message is very long and verbose, so the hint "with value type Utt" is even harder to miss.
  40. But if you just squint really hard, you can see the error: *no overload instance of mkS `<lots of junk>` with value type Utt*.
  41.  
  42. (Obviously this is not easy to see, otherwise I wouldn't be writing this post.)
  43.  
  44. 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,
  45. 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:
  46.  
  47.  
  48. ```haskell
  49. -- Abstract
  50. fun NP_sleeps_Utt : NP -> Utt ;
  51.  
  52. -- Concrete
  53. lin NP_sleeps_Utt np = <mkS (mkCl np sleep_V) : S> ;
  54. ```
  55.  
  56. One thing is that once you write an explicit type annotation, "this RHS is supposed to be an S",
  57. you might notice the mismatch with the LHS, which says Utt.
  58. But suppose you don't notice it (maybe you never updated the name in the first place),
  59. let's see what is the new error message:
  60.  
  61. ```
  62. Happened in linearization of NP_sleeps_Utt
  63. missing record fields: s type of TUseCl TPres ASimul PPos ((\s,v -> PredVP s (UseV v)) np sleep_V)
  64. expected: {s : Str}
  65. inferred: {s : CommonScand.Order => Str; lock_S : {}}
  66. ```
  67.  
  68. Aside from the line `s type of TUseCl …`, which is a bit mysterious (what is T in TUseCl?), this error message is much nicer.
  69. The compile *expects* a `{s : Str}`, but is getting (*infers*) some other type instead.
  70. 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*.
  71.  
  72.  
  73. The solution is just to update the concrete syntax:
  74.  
  75. ```haskell
  76. -- Abstract
  77. fun NP_sleeps_Utt : NP -> Utt ;
  78.  
  79. -- Concrete
  80. lin NP_sleeps_Utt np = mkUtt (mkS (mkCl np sleep_V)) ;
  81. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement