0

I'm trying to use dhall to type an openapi specification. Following the description of a Security Requirement Object which the open api object have an array of, I write the following code:

let SecurityRequirement =
  {
    mapKey: Text
  , mapValue: List Text
  }
in
let req1 : SecurityRequirement =
  { mapKey = "AuthorizationHeader"
  , mapValue = ([] : List Text)
  }
let req2 : SecurityRequirement =
  { mapKey = "Foo"
  , mapValue = ([] : List Text)
  }
let requirements : List SecurityRequirement =
  [ req1, req2 ]
in requirements

With this code, I get {"Foo":[],"AuthorizationHeader":[]} while I'm trying to have [{"Foo":[]},{"AuthorizationHeader":[]}]. How can I achieve my goal ?

lorilan
  • 311
  • 1
  • 9

1 Answers1

0

If you change the type of SecurityRequirement to List { mapKey : Text, mapValue : List Text } then it behaves the way that you requested:

let SecurityRequirement = List { mapKey : Text, mapValue : List Text }

let req1
    : SecurityRequirement
    = [ { mapKey = "AuthorizationHeader", mapValue = [] : List Text } ]

let req2
    : SecurityRequirement
    = [ { mapKey = "Foo", mapValue = [] : List Text } ]

let requirements : List SecurityRequirement = [ req1, req2 ]

in  requirements
$ dhall-to-json <<< './example.dhall' 
[{"AuthorizationHeader":[]},{"Foo":[]}]
Gabriella Gonzalez
  • 34,863
  • 3
  • 77
  • 135