Skip to content

Instantly share code, notes, and snippets.

@gsg
Created July 15, 2015 14:10
Show Gist options
  • Save gsg/c4b1a07229a9d17bf842 to your computer and use it in GitHub Desktop.
Save gsg/c4b1a07229a9d17bf842 to your computer and use it in GitHub Desktop.
type (_, _) arr =
| Const : 'a -> (_, 'a) arr
| Comp : ('a, 'b) arr * ('b, 'c) arr -> ('a, 'c) arr
let rec eval : type a b . a -> (a, b) arr -> b =
fun x arr ->
match arr with
| Const a -> a
| Comp (u, v) -> eval (eval x u) v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment