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

toying around with first-class modules, i’m doing this:

type t = {
  clock: module(Clock.T),
  getLog: string => module(Logger.T),
}

let make = () => {
  module C = SystemClock

  let getLog = (name) => module(ConsoleLogger.Make(C, {let name = name}) : Logger.T)

  {clock: module(C), getLog}
}

it sort of makes more sense, but it’s also a bit clunky. anyway, funnily enough, the rescript formatter that i brought up in the other thread absolutely mangles it:

type t = {
  clock: module(Clock.T),
  getLog: string => module(Logger.T),
}

let make = () => {
  module C = SystemClock

  let getLog = (name): module(Logger.T) =>
    module(
      ConsoleLogger.Make(
        C,
        {
          let name = name
        },
      )
    )

  {clock: module(C), getLog}
}

do i just have to live with this or is there anything i can do? (it even added the return type annotation!)


Viewing all articles
Browse latest Browse all 2592

Trending Articles