type zero
type _ t =
| Nil : zero t
| Cons : ' a * ' b t -> ( ' a * ' b) t
let head ( type s) : ( s * _) t -> s =
function Cons ( a,b) -> a
let tail ( type s) : ( _ * s) t -> s t =
function Cons ( a,b) -> b
let rec length
: type a
. a t
-> int = function | Nil -> 0
| Cons ( a,b) -> 1 + length b
end
let rec from_list
: type a b
. a
list -> b
List . t
= function | x
:: xs
-> List . Cons
( x, from_list xs
)
bW9kdWxlIExpc3QgPSBzdHJ1Y3QKICB0eXBlIHplcm8KICB0eXBlIF8gdCA9CiAgICB8IE5pbCA6IHplcm8gdAogICAgfCBDb25zIDogJ2EgKiAnYiB0IC0+ICgnYSAqICdiKSB0CgogIGxldCBoZWFkICh0eXBlIHMpICA6IChzICogXykgdCAtPiBzICA9CiAgICBmdW5jdGlvbiBDb25zIChhLGIpIC0+IGEKCiAgbGV0IHRhaWwgKHR5cGUgcykgOiAoXyAqIHMpIHQgLT4gcyB0ID0KICAgIGZ1bmN0aW9uIENvbnMgKGEsYikgLT4gYgoKICBsZXQgcmVjIGxlbmd0aCA6IHR5cGUgYSAuIGEgdCAtPiBpbnQgPSBmdW5jdGlvbgogICAgfCBOaWwgLT4gMAogICAgfCBDb25zIChhLGIpIC0+IDEgKyBsZW5ndGggYgplbmQKCmxldCByZWMgZnJvbV9saXN0OiB0eXBlIGEgYi4gYSBsaXN0IC0+IGIgTGlzdC50ID0gZnVuY3Rpb24KICB8IFtdICAgIC0+IExpc3QuTmlsCiAgfCB4Ojp4cyAtPiBMaXN0LkNvbnMoeCwgZnJvbV9saXN0IHhzKQo=
compilation info
File "prog.ml", line 19, characters 13-21:
Error: This expression has type List.zero List.t
but an expression was expected of type b List.t
Type List.zero is not compatible with type b
stdout