Advertisement
Guest User

Untitled

a guest
Mar 20th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module type Functor = sig
  2.     type 'a t
  3.     val fmap : ('a -> 'b) -> 'a t -> 'b t
  4.   end
  5.  
  6. let makeFunctor (type s) ~fmap =
  7.   let module S = struct
  8.     type 'a t = s
  9.     let fmap = fmap
  10.   end
  11.   in (module S : Functor with type t = s)
  12.  
  13. module MyF = (val makeFunctor ~fmap:(fun f v -> match (f, v) with
  14.                                       | (f, (Some x)) -> Some (f x)
  15.                                       | (_, None) -> None))
  16.  
  17. =>
  18. Error: In this `with' constraint, the new definition of t
  19.        does not match its original definition in the constrained signature:
  20.        Type declarations do not match: type t is not included in type 'a t
  21.        They have different arities.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement