Advertisement
Guest User

Untitled

a guest
Dec 1st, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 1.03 KB | None | 0 0
  1. module type EqSig =
  2. sig
  3.   type t;;
  4.   val equal : t -> t -> bool
  5. end;;
  6.  
  7. module EqInt : EqSig with type t = int =
  8. struct
  9.   type t = int;;
  10.   let equal = (=);;
  11. end;;
  12.  
  13. module BigFunctor(E : EqSig) =
  14. struct
  15.   let eqall x y z = E.equal x y && E.equal y z;;
  16.   let alldiff x y z = not (E.equal x y) &&
  17.                       not (E.equal x z) &&
  18.                       not (E.equal y z);;
  19. end;;
  20.  
  21. module FactoredFunctorPart1(E : EqSig) =
  22. struct
  23.   module E = E
  24.   let eqall x y z = E.equal x y && E.equal y z;;
  25. end;;
  26.  
  27. module FactoredFunctorPart2(E : EqSig) =
  28. struct
  29.   module E = E
  30.   let alldiff x y z = not (E.equal x y) &&
  31.                       not (E.equal x z) &&
  32.                       not (E.equal y z);;
  33. end;;
  34.  
  35. module FactoredFunctor(E : EqSig) =
  36. struct
  37.   module FactoredPart1 = FactoredFunctorPart1(E);;
  38.   include (FactoredPart1 : module type of FactoredPart1 with module E := E);;
  39.   module FactoredPart2 = FactoredFunctorPart2(E);;
  40.   include (FactoredPart2 : module type of FactoredPart2 with module E := E);;
  41. end;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement