fork download
  1. module List = struct
  2. type zero
  3. type _ t =
  4. | Nil : zero t
  5. | Cons : 'a * 'b t -> ('a * 'b) t
  6.  
  7. let head (type s) : (s * _) t -> s =
  8. function Cons (a,b) -> a
  9.  
  10. let tail (type s) : (_ * s) t -> s t =
  11. function Cons (a,b) -> b
  12.  
  13. let rec length : type a . a t -> int = function
  14. | Nil -> 0
  15. | Cons (a,b) -> 1 + length b
  16. end
  17.  
  18. let rec from_list: type a b. a list -> b List.t = function
  19. | [] -> List.Nil
  20. | x::xs -> List.Cons(x, from_list xs)
  21.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
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
Standard output is empty