Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module type Functor = sig
- type 'a t
- val fmap : ('a -> 'b) -> 'a t -> 'b t
- end
- (* first version: DOES NOT WORK *)
- let makeFunctor1 (type s) ~fmap =
- let module S = struct
- type 'a t = s
- let fmap = fmap
- end
- in (module S : Functor with type t = s)
- module MyF = (val makeFunctor ~fmap:(fun f v -> match (f, v) with
- | (f, (Some x)) -> Some (f x)
- | (_, None) -> None))
- =>
- Error: In this `with' constraint, the new definition of t
- does not match its original definition in the constrained signature:
- Type declarations do not match: type t is not included in type 'a t
- They have different arities.
- (* second version: DOES NOT WORK EITHER *)
- let makeFunctor (type s) ~fmap =
- let module S = struct
- type 'a t = s
- let fmap = fmap
- end
- in (module S : Functor with type 'a t = s)
- =>
- Parse error: [ident] expected after "type" (in [package_type_cstr])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement