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

Module functors vs. records-of-functions for interface/implementation separation

$
0
0

do i understand you correctly, you’d suggest something like this?

// Clock.res
module type T = {
  let now: unit => float
}

// SystemClock.res
let now = () => {
  Date.make()->Date.getTime->Float.toInt
}

// Deps.res (composition root)
type t = {clock: module(Clock.T)}

let make = () => {
  let clock = module(SystemClock: Clock.T)

  {clock: clock}
}

just as an example. am i on the right track?


Viewing all articles
Browse latest Browse all 2592

Trending Articles