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

Enforce the same generic type between two functions

$
0
0

something like that:

module MakeScene = (
  Specification: {
    type scenes = private string
  },
) => {
  external scene: (Specification.scenes, 'a => unit) => unit = "scene"

  external go: (Specification.scenes, ~data: 'a=?) => unit = "go"
}

module Spec1: {
  type scenes = private string
  let one: scenes
  let two: scenes
} = {
  type scenes = string
  let one = "one"
  let two = "two"
}

module Scene1 = MakeScene(Spec1)

Scene1.scene(Spec1.one, _val => ())
Scene1.go("other") // compiler error!

Playground link


Viewing all articles
Browse latest Browse all 2592

Trending Articles