module type Format = sig type t = int val to_int : t -> int (** other format specific functions *) end module type Maker = functor (F : Format) -> sig type bin (** common implementation functions *) val unsafe_b : bin -> t val unsafe_s : t -> bin val to_int : bin -> int end module LittleEndian : Format = struct type t = int let to_int n = 1 end module BigEndian : Format = struct type t = int let to_int n = 2 end module Make : Maker = functor (F : Format) -> struct type bin = F.t let unsafe_b (b : bin) = b let unsafe_s (s : t) = s let to_int = F.to_int end