Skip to content

Instantly share code, notes, and snippets.

@Octachron
Created July 1, 2021 21:50
Show Gist options
  • Save Octachron/5e5cd4d5d72435d5c3a28224fdfeffc6 to your computer and use it in GitHub Desktop.
Save Octachron/5e5cd4d5d72435d5c3a28224fdfeffc6 to your computer and use it in GitHub Desktop.
type 'a s = private Succ
type ('elt,'size) t =
| [] : ('elt, 'a -> 'a) t
| (::): 'elt * ('elt, 'z -> 'k) t -> ('elt, 'z -> 'k s) t
let rec (@): type elt low mid high.
(elt, mid -> high) t -> (elt, low -> mid) t -> (elt, low -> high) t =
fun l r ->
match l with
| [] -> r
| a :: q -> a :: (q @ r)
let wrong x y =
x @ y, x @ 1 :: y
let lit = [1;2]
let ok = lit @ [1], lit @ lit
let lookalike = [1] @ [2]
let wrong_2 = lookalike @ [1], lookalike @ lookalike
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment