I am new to OCaml and I am trying to convert some Haskell code to OCaml.
I have the following code, where I explore the OCaml module system and functors.
module type F =
sig
type 'a f
val fmap : ('a -> 'b) -> 'a f -> 'b f
end
module type FOO =
functor (C : F) ->
sig
type f
end
module Foo : FOO =
functor (C : F) ->
struct
type f = { foo : 'x . 'x C.f -> 'x ;
bar : 'x . 'x C.f -> 'x C.f }
end
module List =
struct
include List
type 'a f = 'a list
let fmap = List.map
end
module Bar =
struct
include Foo (List)
let ea = { foo = List.hd ; bar = List.tl }
end
I keep having the error Unbound record field foo.
The fact that Foo is a functor complicates matters, I feel like I cannot provide an annotation as I want to.
What am I missing?