That's because StateType
is the type of a functor, not a module.
You should declare StateType
as
module type StateType =
sig
type event
type state_t = {
mutable event_success : event option;
}
val set_event_success : state_t -> event option -> unit
val create : unit -> state_t
end
and the functor State
as
module State (E : E) : (StateType with type event = E.event) =
struct
type event = E.event
type state_t = {
mutable event_success : event option;
}
let create () = {
event_success = None;
}
let set_event_success s e = (s.event_success <- e;)
end
How to solve this kind of problems:
Don't write functor types.
Instead write the signature of the output module and use with type
to add type equations.
For Agent
, the output signature would be be
module type AgentType =
sig
type event
type state_t
end
and the Agent
functor would look like
module Agent (S : StateType) (E : E) : (AgentType with type event = E.event and type state_t = S.state_t) = …