On Fri, Oct 28, 2016 at 9:28 AM, Shayne Fletcher <shayne.fletcher.50@gmail.com> wrote:
On Fri, Oct 28, 2016 at 9:25 AM, Nicolas Ojeda Bar <nicolas.ojeda.bar@lexifi.com> wrote:
You can add a constrain to your functor arguments :

module type MUL = functor (E : EQ) (N : NUM with type t = E.t) ->
    MUL_S with module N := N and module E := E

​That does it! I tried so many different things :) You're a rock 'n roll star.

​Still stuck on how to achieve this I'm afraid.

module type EQ = sig
  type t
  val eq : t * t -> bool
end

module type NUM = sig
  type t
  val from_int : int -> t
  val ( + ) : t -> t -> t
end

module type MUL_S = sig
  include EQ
  include NUM with type t := t

  val mul : t -> t -> t
end

module type MUL = functor (E : EQ) (N : NUM with type t = E.t) -> MUL_S

module Mul_default (E : EQ) (N : NUM with type t = E.t) : MUL  = struct

  include E
  include (N : NUM with type t := E.t)

  let mul (x : t) (y : t) : t = failwith "foo"

end

Yields.

​Error: Signature mismatch:
       Modules do not match:
         sig
           type t = E.t
           val eq : t * t -> bool
           val from_int : int -> E.t
           val ( + ) : E.t -> E.t -> E.t
           val mul : t -> t -> t
         end
       is not included in
         MUL​

--
Shayne Fletcher