I'm new to module programming using ocaml. I made a dictionary module such as
module type DICT =
sig
type key
type 'a dict
...
val lookup : 'a dict -> key -> 'a option
...
end
module DictList : DICT with type key = string =
struct
type key = string
type 'a dict = (key * 'a) list
...
**let rec lookup d k =
match d with
| [] as dict -> None
| (key, value)::tl as dict -> if( key = k ) then (key, value)
else lookup tl k**
...
end
lookup d k searches the key k in the dictionary d. If the key is found, it returns the item, otherwise, it returns None. However, I got a error which says
Error: This expression has type 'a * 'b but an expression was expected of type 'c list
at lookup function. What is the problem and how can I fix it?