Guest User

Untitled

a guest
Oct 10th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. module type Format = sig
  2. type t = int
  3. val to_int : t -> int
  4. (** other format specific functions *)
  5. end
  6.  
  7. module type Maker = functor (F : Format) ->
  8. sig
  9. type bin
  10. (** common implementation functions *)
  11. val unsafe_b : bin -> t
  12. val unsafe_s : t -> bin
  13. val to_int : bin -> int
  14. end
  15.  
  16. module LittleEndian : Format = struct
  17. type t = int
  18. let to_int n = 1
  19. end
  20.  
  21. module BigEndian : Format = struct
  22. type t = int
  23. let to_int n = 2
  24. end
  25.  
  26. module Make : Maker = functor (F : Format) ->
  27. struct
  28. type bin = F.t
  29. let unsafe_b (b : bin) = b
  30. let unsafe_s (s : t) = s
  31. let to_int = F.to_int
  32. end
Add Comment
Please, Sign In to add comment