Skip to content

Instantly share code, notes, and snippets.

@destrius
Created April 29, 2016 07:44
Show Gist options
  • Save destrius/85cc9c6f09173850bccd15259946bb53 to your computer and use it in GitHub Desktop.
Save destrius/85cc9c6f09173850bccd15259946bb53 to your computer and use it in GitHub Desktop.
(* Type of data record *)
type rectype = CharArray | Number
(* My type *)
type _ mytype =
| String : string mytype
| Bool : bool mytype
| Int : int mytype
(* Check that data record type is compatible with my type *)
let validate (type a) (ty : a mytype) (v : rectype) =
match (ty, v) with
| (String, CharArray)
| (Bool, Number)
| (Int, Number) -> true
| _ -> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment