Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Uncomment below line to see error */
- /* exception Absurd('a); */
- /* ^^ Error: Unbound type parameter 'a */
- /*
- Normally, exceptions are monomorphic. They usually cannot take in type params...
- */
- /*
- ...But what if we skip the `exception` syntax sugar and just use the `+=` open
- variant extension syntax in tandem with GADT syntax? Aha! We've done the impossible!
- */
- type exn +=
- | Absurd('a) : exn;
- let absurdString = Absurd("lol");
- let absurdInt = Absurd(0);
- let absurdPolyVar = Absurd([ `LolWut ]);
- raise(absurdString);
- /* raise(absurdInt); */
- /* raise(absurdPolyVar); */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement