Search code examples
dhall

How to use merge with abstract type?


I'm trying to implement a generic procedure that uses merge with an abstract type, but it always fail with ❰merge❱ expects a record of handlers, even when the caller pass a record type:

let Keys
    : Type
    = < A | B >

let ConfigType
    : Type
    = { A : Text, B : Text }

let Renderer =
        λ(configType : Type)
      → λ(config : configType)
      → λ(value : Keys)
      → merge config value

in  Renderer ConfigType { A = "A", B = "B" } Keys.A

Is it possible to indicate that configType will be a record type so that this generic method can be interpreted?


Solution

  • No, this is currently not possible within the language.

    In the following GitHub issue we discussed adding a Row kind to the language to distinguish record types from other types:

    https://github.com/dhall-lang/dhall-lang/issues/434

    ... but ultimately solved the original problem in a different manner.