Skip to content

Instantly share code, notes, and snippets.

@moonlightdrive
Created March 14, 2015 17:05
Show Gist options
  • Save moonlightdrive/2fcb33f26b72bbe6197d to your computer and use it in GitHub Desktop.
Save moonlightdrive/2fcb33f26b72bbe6197d to your computer and use it in GitHub Desktop.
The type constructor would escape its scope (or, what on earth is this error?)
type _ value = Bool : bool -> bool value
| Int : int -> int value
type _ atom = Abool : bool -> bool atom
| Aint : int -> int atom
type _ sexp = Sexp_atom : 'a atom -> 'b atom sexp
let val_of_atom : type t. t atom -> t value =
function
| Abool b -> Bool b
| Aint i -> Int i
let val_of_sexp = function
| Sexp_atom a -> val_of_atom a
(*
Error: This expression has type a#0 value
but an expression was expected of type a#0 value
The type constructor a#0 would escape its scope
"This expression" being `val_of_atom a` in val_of_sexp
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment