Skip to content

Instantly share code, notes, and snippets.

@mheiber
Last active February 27, 2023 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mheiber/798e1c8b1bda11a748e61ed167d9d08a to your computer and use it in GitHub Desktop.
Save mheiber/798e1c8b1bda11a748e61ed167d9d08a to your computer and use it in GitHub Desktop.
vector ocaml dependent vector
type zero = unit * unit
type 'a minus1 = 'snd constraint 'a = unit * 'snd
type 'a plus1 = unit * 'a
type _ lst =
| [] : zero lst
| ( :: ) : int * 'b lst -> ('b lst) plus1 lst
let cons n lst = n :: lst
let hd = function
| h :: _ -> h
let tl = function
| _ :: t -> t
let l0 = []
let l1 = 1 :: l0
let l2 = 2 :: l1
let l1' = tl l2
let l0' = tl l1
let _ = tl l0' (* error *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment