Skip to content

Instantly share code, notes, and snippets.

@Nymphium
Last active July 28, 2019 18:14
Show Gist options
  • Save Nymphium/7aa21f8b3ad4c755a924d140aa789db3 to your computer and use it in GitHub Desktop.
Save Nymphium/7aa21f8b3ad4c755a924d140aa789db3 to your computer and use it in GitHub Desktop.
effect Id : 'a -> 'a;;
let handler th =
match th () with
| x -> x
| effect (Id v) k -> continue k v;;
let handler' th =
match th () with
| x -> x
| effect (Id (v' : int)) k -> continue k (v' + 3)
| effect (Id v) k -> continue k v;;
(*
File "test.ml", line 11, characters 17-27:
Error: This pattern matches values of type int
but a pattern was expected which matches values of type effect
*)
let header'' th =
match th () with
| x -> x
| effect (Id v) k -> v
(*
File "test.ml", line 22, characters 23-24:
Error: This expression has type effect but an expression was expected of type
'a
The type constructor effect would escape its scope
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment