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

Unions between polymorphic variants behind module types

$
0
0

i’m trying to compose two modules in a Module Function and i’d like for them to be able to expand a return type. i essence, im trying to do this:

module type T = {
  type t<'a> = [> ] as 'a
}

module A: T = {
  type t<'a> = [> #a] as 'a
}

module B: T = {
  type t<'a> = [> #b] as 'a
}

module C = {
  type t = [A.t | B.t]
  let a: t = #b
}

but it’s giiving me this error:


  42 │ }
  43 │
  44 │ module A: T = {
  45 │   type t<'a> = [> #a] as 'a
  46 │ }
  47 │
  48 │ module B: T = {

  Signature mismatch:
  Modules do not match:
    {
  type t<'a> = 'a
    constraint 'a = [> #a]
}
  is not included in
    T
  Type declarations do not match:
    type t<'a> = 'a
  constraint 'a = [> #a]
  is not included in
    type t<'a> = 'a
  constraint 'a = [> ]
  /home/spec1/Dropbox/desktop/rescript-homework/hw7/src/main.res:41:3-25:
    Expected declaration
  /home/spec1/Dropbox/desktop/rescript-homework/hw7/src/main.res:45:3-27:
    Actual declaration

iirc i can do this in ocaml. am i doing it incorrectly or is pv across module boundaries just not possible in rescript?


Viewing all articles
Browse latest Browse all 2592

Trending Articles