Skip to content

Instantly share code, notes, and snippets.

@Octachron
Created November 18, 2015 22:27
Show Gist options
  • Save Octachron/6bbfb9a744a908ef2777 to your computer and use it in GitHub Desktop.
Save Octachron/6bbfb9a744a908ef2777 to your computer and use it in GitHub Desktop.
module Natl =struct
type z = Nil_z
type 'a succ = Nil_succ
end
open Natl
type _ t =
| Nil: <f:'a; t:'a; dim:z > t
| Cons:
'elt * <f:'ty; t:'ret; dim:'d > t -> <f: 'elt -> 'ty; t:'ret; dim:'d succ> t
let rec apply : type arg ret d .
arg -> < f :arg; t:ret; dim:d> t -> ret = fun f l->
match l with
| Nil -> f
| Cons (a,Nil) -> f a
| Cons(a, ( Cons _ as l ) ) -> apply (f a ) l
module Infix = struct
let (@@) f l = apply f l
let (|>) l f = apply f l
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment