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

The big migration thread for ReScript v11 (and uncurried mode)

$
0
0

I have an opaque type that I want to create an immutable set for. In order to do that in a type safe manner I’ve defined a module type for Belt.Set (since one isn’t provided out-of-the-box). This worked fine in v10 and v11 with uncurrying disabled, but in uncurried mode it breaks with the cryptic error seen below. I understand there’s a curried/uncurried function type mismatch, and I’m guessing the compiler is trying to tell me that I need to make the function type curried somehow, but I have no idea how to specify a curried function of arity 1.

tl;dr: How can I fix the module type so that it matches the actual type of Belt.Set?

Minimal reproducible example:

module type S = {
  type value
  type t

  let fromArray: array<value> => t
}

module Id: {
  type id
  module Set: S with type value = id
} = {
  type id = int
  module Set = Belt.Set.Int
}

yields

[E] Line 11, column 4:
Signature mismatch:
  ...
  In module Set:
  Values do not match:
    let fromArray: array<value> => t (curried)
  is not included in
    let fromArray: array<value> => t (uncurried)
  playground.res:5:3-34: Expected declaration
  playground.res: Actual declaration

Full playground example:


Viewing all articles
Browse latest Browse all 1948

Trending Articles