Questions tagged [dhall]

Dhall is a total programming language tailored for configuration files.

62 questions
11
votes
1 answer

Can the type of valid graphs be encoded in Dhall?

I'd like to represent a wiki (a set of documents comprising a directed graph) in Dhall. These documents will be rendered to HTML, and I'd like to prevent broken links from ever being generated. As I see it, this could be accomplished either by…
11
votes
1 answer

How do I represent a tuple in dhall?

I would like to represent IPv4 addresses in dhall, so I can manage my host configurations. By default, this is held as Text; but that's clearly unsatisfactory as it allows any old text to slip through. I would like to keep these values as a 4-tuple…
user3416536
  • 1,429
  • 9
  • 20
6
votes
1 answer

Splitting a string in dhall

I'm playing with dhall and wondered how I can implement a string splitting function of the form λ(text: Text) -> λ(delimiter: Text) -> List Text However, it appears dhall has no concept/type to represent individual characters. and there's no such…
Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172
6
votes
1 answer

How to define and use a Haskell-like sum type in Dhall

How can I define a sum type analogous to Haskell's sum types in the Dhall programming language? For instance, if in Haskell I'd define data SumProp = Option1 | Option2 My purpose is to define in Dhall a record in which one of its properties has a…
Jesuspc
  • 1,664
  • 10
  • 25
5
votes
1 answer

How to create a dhall schema with arbitrary key but typed values?

In dhall, how can I create a schema for the following yaml? environment: local: path: "/path/to/env" envvars: - var1 - var2 stage: path: "/path/to/env" envvars: - var1 …
kjq07bd
  • 125
  • 1
  • 4
5
votes
1 answer

Is there a way to generate a dhall schema from an haskell datatype?

I'm trying to rewrite a BIG yaml configuration file used in Haksell applicationusing dhall. To do so I'm using json-to-dhall which requires a SCHEMA which is the type of the resuting expression. The problem is the actual schema is almost impossible…
mb14
  • 22,276
  • 7
  • 60
  • 102
5
votes
1 answer

Difference between `dhall format` and `dhall lint`

Playing with dhall for the first time I saw that it supports these two options: ./dhall --help ... lint Improve Dhall code format Formatter for the Dhall language What's the difference between the two?…
Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172
4
votes
1 answer

How to use polymorphic type constructors in dhall

I am trying to define a polymorphic type in Dhall. In Haskell it would look like: data MyType a = Some a | SomethingElse To do so I have defined this function in Dhall (mkMyType.dhall): let SomethingElse = ./SomethingElse.dhall in λ(a : Type) → <…
Jesuspc
  • 1,664
  • 10
  • 25
3
votes
2 answers

Integer division in Dhall

I would like to compute the quotient of two Naturals. The requirement I need to fulfill is that I have a few configuration items that must be dynamically defined as shares of another (i.e. one container has X memory, two configuration keys for the…
3
votes
1 answer

How to write a function that handles a Union type in Dhall

I'm trying to wrap my head around how programming works in Dhall. Consider the following union type: let Object = < NoId | WithId : Text > I want to write a function extractId that returns an Optional Text containing the Id (or None), but I can't…
Julian Stecklina
  • 1,271
  • 1
  • 10
  • 24
3
votes
1 answer

Dynamic records key type

I'm trying to generate some YAML containing a map with dynamic keys, as described here. This works if I use Text keys, but not when the keys have any other type. I'd like to use a union type for the keys if possible. I've tried using different types…
DaveWM
  • 56
  • 3
3
votes
1 answer

How to represent "Data.Map Text Text" in Dhall?

If I have a type in Haskell like this: data MyType = MyType { env :: Map Text Text } How can I represent a value of MyType in Dhall? { env = ??? } What I want to do is to write values of MyType in Dhall and then read it in from Haskell and…
Linus Arver
  • 1,331
  • 1
  • 13
  • 18
2
votes
1 answer

Gradual typing in Dhall

The Dhall website has a nice example: {- You can optionally add types `x : T` means that `x` has type `T` -} let Config : Type = {- What happens if you add another field here? -} { home : Text , privateKey : Text ,…
Felix
  • 8,385
  • 10
  • 40
  • 59
2
votes
1 answer

dhall Invalid alternative type

I've defined a union type with two elements like so: FunctionCode.dhall {- Function Code union -} let StaticFC = ./StaticFunctionCode.dhall let DynamicFC = ./DynamicFunctionCode.dhall in < Static : StaticFC | Dynamic : DynamicFC > The two types,…
dangeroushobo
  • 1,291
  • 2
  • 16
  • 28
2
votes
1 answer

What is the difference between packages.dhall and spago.dhall files?

spago docs state: packages.dhall: this file is meant to contain the totality of the packages available to your project (that is, any package you might want to import). In practice it pulls in the official package-set as a base, and you are then…
bela53
  • 3,040
  • 12
  • 27
1
2 3 4 5