fork download
  1. type 'a tree =
  2. | Leaf of 'a
  3. | Branch of ('a * 'a) tree;;
  4.  
  5. let help (f:'a->'b) (p:'a * 'a):('b * 'b) =
  6. match p with
  7. (x,y) -> (f x, f y)
  8.  
  9. let rec map (f:'a->'b) (t:'a tree):('b tree) =
  10. match t with
  11. | Leaf (x:'a) -> ((Leaf (f x:'b)):'b tree)
  12. | Branch (st:('a * 'a) tree) -> ((Branch (map (help f) st)):'b tree)
  13.  
  14.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
File "prog.ml", line 12, characters 50-58:
This expression has type 'a * 'a -> 'b * 'b but is here used with type
  'a -> 'b
stdout
Standard output is empty