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

Module-scoped type as alias?

$
0
0

Hello,

Consider the following module type definition:

module type Comparable = {
  type t
  let equal: (t, t) => bool
}

Now, the CmpInt module instance of the module type Comparable:

module CmpInt: Comparable = {
  type t = int
  let equal = (x: int, y: int) => x === y
}

If I write:

let x = CmpInt.equal(1, 1)

I get the compile error:

This has type: int
But this function argument is expecting: CompInt.t

CmpInt.t and int are considered different types. However, I expected CmpInt to be an alias for int.

Can I get CmpInt.t behaving as an alias for int?

Thanks in advance


Viewing all articles
Browse latest Browse all 1941

Trending Articles