Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. /* Uncomment below line to see error */
  2. /* exception Absurd('a); */
  3. /* ^^ Error: Unbound type parameter 'a */
  4.  
  5. /*
  6. Normally, exceptions are monomorphic. They usually cannot take in type params...
  7. */
  8.  
  9. /*
  10. ...But what if we skip the `exception` syntax sugar and just use the `+=` open
  11. variant extension syntax in tandem with GADT syntax? Aha! We've done the impossible!
  12. */
  13. type exn +=
  14. | Absurd('a) : exn;
  15.  
  16. let absurdString = Absurd("lol");
  17. let absurdInt = Absurd(0);
  18. let absurdPolyVar = Absurd([ `LolWut ]);
  19.  
  20. raise(absurdString);
  21. /* raise(absurdInt); */
  22. /* raise(absurdPolyVar); */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement