Skip to content

Instantly share code, notes, and snippets.

@destrius
Created April 29, 2016 07:44
(* 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