Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Module types for multi-argument functors

$
0
0

Hi all, I have a module function of multiple arguments (simplified here), where the second argument depends on the first.:

module Example = (A : {type t}, B : {let x : A.t}) => { ... }

In reality, the module types for the arguments A and B are much larger, so I want to define some module types for them, but I can’t see how to declare the type of B separately where the module A is in scope.

module type AType = {type t}
module type BType = ???

Currently my solution is to “curry” the modules:

module type AType = {type t}
module Example0 = (A : AType) => {
  module type BType = { A.t }
  module Example1 = (B : BType) => {
    ...
  }
}

But this is a bit annoying because then to fully apply the functors I would have to introduce a bunch of intermediate modules:

module MyExample0 = Example0(MyA)
module MyExample = MyExample0.Example1(MyB)

Is there a better way to do this??


Viewing all articles
Browse latest Browse all 2592

Trending Articles