I have a function in OCaml which should merge two lists:
let rec merge (list1, list2) =
match (list1, list2) with
([], []) -> merge (List.tl list1, List.tl list2) :: List.hd list1 :: List.hd list2
|(_, []) -> merge (List.tl list1, list2) :: List.hd list1
|([], _) -> merge (list1, List.tl list2) :: List.hd list2;;
but for some reason the compiler doesn't let this code through exitting with:
Error: This expression has type 'a list but an expression was expected of type 'a The type variable 'a occurs inside 'a list
How can I specify that these are lists of 'a I'm trying pass, not 'a?