dhall-lang / dhall-haskell

Maintainable configuration files
https://dhall-lang.org/
BSD 3-Clause "New" or "Revised" License
908 stars 211 forks source link

dhall-toml doesn't seem to support serializing Prelude.JSON.Type #2468

Open lf- opened 1 year ago

lf- commented 1 year ago

I actually also don't know if this is even a reasonable request: such a function would be partial, since null does not exist in toml.

let Prelude = https://prelude.dhall-lang.org/package.dhall

in  Prelude.JSON.object [{mapKey = "nya", mapValue = Prelude.JSON.string "nya"}]
dhall-to-toml: Error: The root object converted to TOML must be a record

Explanation: A TOML file must represent a table, so primitive values and
❰List❱s cannot be converted by themselves. Consider nesting the value in a
record with arbitrary fields.

For example, from:
    ┌────┐
    | 42 |
    └────┘
into
    ┌────────────────────────┐
    | { meaningOfLife = 42 } |
    └────────────────────────┘

↳ λ(_ : Type) →
  λ ( _
    : { array : List _ → _@1
      , bool : Bool → _@1
      , double : Double → _@1
      , integer : Integer → _@1
      , null : _
      , object : List { mapKey : Text, mapValue : _ } → _@1
      , string : Text → _@1
      }
    ) →
    _.object [ { mapKey = "nya", mapValue = _.string "nya" } ]