Questions tagged [dhall]

Dhall is a total programming language tailored for configuration files.

62 questions
1
vote
1 answer

Missing record field: IngressServiceBackend

I'm getting a strange error message which I don't understand when trying to use Dhall for Kubernetes. Here is my configuration: let k8s = ./k8s.dhall let utils = ./utils.dhall let Env = utils.Env in \(env : Env) -> k8s.Ingress::{ ,…
damd
  • 6,116
  • 7
  • 48
  • 77
1
vote
0 answers

Dhall environment variable value as a union alternative

I'm just starting out with Dhall and I've been stumped by this problem. I'm trying to generate YAML files where an argument is set by an environment variable, in this case DHALL_TARGET. Basically I'm trying to do this: let Env = < demo | live > in …
damd
  • 6,116
  • 7
  • 48
  • 77
1
vote
1 answer

How can I encode a rule tree of multiple depths in Dhall?

I'm trying to move some error prone YAML into Dhall to make some system configuration simpler. I have a tree that looks like: composite: condition: And rules: - composite: condition: And rules: - leaf: …
fncomp
  • 6,040
  • 3
  • 33
  • 42
1
vote
1 answer

Why doesn't Dhall allow returning types from if expressions?

Dhall has functions that return types: let f = \(b : Bool) -> Natural -- ok And it has if expressions: let f = \(b: Bool) -> if b == True then 1 else 0 -- ok But the two features can't be used together: -- Error: ❰if❱ branch is…
Max Heiber
  • 14,346
  • 12
  • 59
  • 97
1
vote
1 answer

Dhall Repl: How to get the type of field of record type

I'm looking for a way to see the type of field of a record type, basically a type-level equivalent of . in the Dhall REPL Suppose I've done: :let Person = { name : Text, age : Natural } How would I find the type of Person.name (i.e. Text) without…
1
vote
1 answer

Parsing Path type

I was trying to make an instance for the Path type. https://hackage.haskell.org/package/path If I use the generic. instance FromDhall (Path Rel Dir) This doesn't do any normalisation of directories. I initially assumed this would piggyback off the…
1
vote
1 answer

`bind`/`flatMap`/`>>=` over Optional in Dhall

I needed to bind/flatMap/>>= over an Optional in Dhall. I could not find an implementation for it and came up with my own. let bindOptional : ∀(a : Type) → ∀(b : Type) → (a → Optional b) → Optional a → Optional b = λ(a : Type) → λ(b :…
stefanobaghino
  • 11,253
  • 4
  • 35
  • 63
1
vote
1 answer

How to convert structure to json in dhall?

How do I convert arbitrary structure into json? let Prelude = ./include/Prelude.dhall let JSON = Prelude.JSON let Foo = { a: Natural, t: Text } let foo = { a = 10, b = "foo" } in (DO_MAGIC foo) : JSON.Type I know there is toMap builtin function,…
KAction
  • 587
  • 2
  • 10
1
vote
1 answer

dhall-to-yaml funtion Text output is being output in double quotes

I have the following function which its output get enclosed with double quotes when processed via dhall-to-yaml yet a static string injected in a record is not enclosed in quotes, how can I control what get enclosed in double quotes and what…
MrX
  • 424
  • 5
  • 15
1
vote
1 answer

How to make a recursive Dhall sum type containing data

Here is my example code. I haven't been able to figure out how to make my State sum-type recursive, while still allowing it to be used like a sum-type elsewhere. Likewise with my StateMachine type. let State = < Task : { Comment : Text,…
Stats4224
  • 778
  • 4
  • 13
1
vote
1 answer

Encoding `Map ([Text], [Text]) Text` in dhall (Haskell)

What is the best way to encode the Haskell type Map ([Text], [Text]) Text in dhall? Attempt. It seems we can't use toMap to do this: -- ./config.dhall toMap { foo = "apple", bar = "banana"} : List { mapKey : Text, mapValue : Text } x <- input auto…
George
  • 6,927
  • 4
  • 34
  • 67
1
vote
1 answer

Is it possible to create YAML from _within_ a dhall expression?

I would like to generate a ConfigMap for a service using dhall-kubernetes. The service is configured using a YAML file. I can use dhall to create the config in two passes: $ dhall-to-yaml < server.dhall > server.yaml $ dhall-to-yaml <…
user2515975
  • 1,052
  • 1
  • 11
  • 18
1
vote
1 answer

Dhall Record to Text

I'm looking for the Dhall equivalent of Java's toString so I can embed some raw JSON inside another record, but I wish to ensure the resulting JSON structure is valid. I have a Record, e.g. { name : Text, age : Natural } and wish to convert a value…
Alex
  • 8,093
  • 6
  • 49
  • 79
1
vote
1 answer

How to encode union on the subset of fields using Dhall?

I'm trying to use Dhall to generate AWS Cloudformation and the first thing I'm trying to encode is AWS::ApiGatewayV2::Api. Which has following the json spec: { "Type" : "AWS::ApiGatewayV2::Api", "Properties" : { "ApiKeySelectionExpression" :…
LambdaStaal
  • 537
  • 2
  • 9
1
vote
1 answer

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 …
tristanC
  • 35
  • 4