64
questions
0
votes
2
answers
69
views
Parse JSON in Dhall
Dhall is famous for generating JSON, namely from input.dhall to output.json. Is it possible to write a “JSON transformer” in Dhall, namely “input.json + rules.dhall → output.json”? It still sounds ...
1
vote
1
answer
102
views
Is there an elegant way to "override" Dhall records in Haskell?
I'm using Dhall to accept user configurations. Some field are compulsory while the others are optional, whose default values should be used when left unspecified by the user.
This is what I currently ...
1
vote
1
answer
66
views
Dhall: using non-ascii characters as labels in records?
{ "ハルカナホシノセカイへ": "https://www.youtube.com/watch?v=pwl1nISaCNg" }
Simply put, is it yet possible to use non-ascii e.g. CJK characters in the labels of Dhall records? Like, to ...
1
vote
1
answer
231
views
dhall-to-yaml: How to consume args value into it
Context: I would like to create the template of service yaml config and pass corresponding parameter or argument to generate different app config file.
And the problem I got is how to pass the arg ...
1
vote
0
answers
46
views
Dhall double encodes %2F
I'm using the Gitlab API that needs part of the path URL encoded when fetching files, but for some reason Dhall double-encodes my URL (example uses just google.com to minimize):
Welcome to the Dhall ...
2
votes
1
answer
104
views
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? -}
{ ...
0
votes
1
answer
134
views
"unexpected end of input" in `dhall repl`
I can evaluate dhall expressions with dhall --file ..., and I can evaluate 1 + 1 in the repl, but typing a let expression into dhall repl fails with "unexpected end of input."
➜ cat test....
1
vote
1
answer
69
views
Prelude dhall Error: Connection establishment took too long
Today my dhall project has started crashing on Prelude dependencies, so the main error is:
Error: Connection establishment took too long.
I use this deps:
let List/map = https://prelude.dhall-lang....
0
votes
1
answer
39
views
Reverse a N-N mapping of data in Dhall
Given is a config of apps and containers with an app being able to have multiple containers a container being able to have multiple apps. I want to be able to output them in 2 ways
Per app list the ...
0
votes
1
answer
83
views
How can I write a ToDhall instance for a ByteString, in Haskell?
So I have a simple data structure that has some ByteStrings. I want to serialize these into Dhall files. However, I apparently can't just automatically derive ToDhall, since there's no instance for ...
1
vote
1
answer
84
views
Dhall Repl: strange formatting issues (Powershell on Windows 10 64bit)
When I'm working with dhall repl in Powershell I get a lot of weird output / encoding issues.
I'm using the precompiled binaries for windows from https://github.com/dhall-lang/dhall-haskell/releases.
...
1
vote
1
answer
214
views
Encoding recursive types to JSON using Dhall
A simplified version of my desired output:
{
"dynamic-name": {
"type": "type",
"fields": {
"inner-dynamic-name": {
"type&...
2
votes
1
answer
118
views
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 ...
1
vote
0
answers
24
views
How to get more context in extractError?
I have this for decoding well-typed Paths
pathDecoder f opts =
Decoder
{ extract = extractPath
, expected = expectedPath
}
where
filePathDecoder ...
0
votes
1
answer
406
views
Dhall - Expression doesn't match annotation, type Text expected
I'm working with Dhall 1.39.0 and getting this error:
Error: Expression doesn't match annotation
- Text
+ { … : … } (a record type)
[snip]
You or the interpreter annotated this expression:
[ file ...
0
votes
1
answer
312
views
How to type a heterogeneous list in dhall?
I'm using Dhall to generate a Yaml file for github action. In GH Action, you can specify a matrix to generate multiple cases (e.g. combination of Scala version and project name). But you can also ...
1
vote
1
answer
101
views
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
...
1
vote
0
answers
166
views
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 ...
2
votes
1
answer
495
views
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 ...
0
votes
1
answer
153
views
how can i export IntOrString from dhall kubernetes
i want to import : IntOrString from dhall kubernetes,
https://github.com/dhall-lang/dhall-kubernetes/blob/master/1.19/types/io.k8s.apimachinery.pkg.util.intstr.IntOrString.dhall;
but i don't know how ...
1
vote
1
answer
81
views
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: ...
1
vote
1
answer
341
views
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 ...
1
vote
1
answer
391
views
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 ...
1
vote
1
answer
69
views
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. ...
3
votes
2
answers
234
views
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 ...
1
vote
1
answer
143
views
`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) → ...
0
votes
1
answer
185
views
Defining a list of complex Type in dhall
I have several types defined and two are organized into list (field and option). Functions are defined to help define entries (addfield and addoption). I'm able to define fields and works as expected; ...
1
vote
1
answer
531
views
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 ...
0
votes
1
answer
237
views
How can I print/encode a value into Dhall?
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
import Dhall
data Example = Example { foo :: Natural, bar :: Vector Double }
deriving (Generic, Show)
instance Interpret ...
1
vote
1
answer
253
views
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 ...
5
votes
1
answer
401
views
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/...
1
vote
1
answer
155
views
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.
...
1
vote
1
answer
227
views
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 {...
0
votes
1
answer
187
views
Dhall Lang Invalid List Type
I am really wanting to use Dhall lang to solve an issue that I have with using the Github Terraform Provider.
See: https://github.com/etaty/example-dhall-terraform-github
However, I have never used ...
2
votes
0
answers
46
views
Is there a way to show a Double with no scientific notation in Dhall?
I'm using dhall as a means of defining certain structs which can accept decimals and integers as input. I used the Double type for this as it seemed like a good fit to cover both cases, but I'm ...
1
vote
1
answer
171
views
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 < ...
2
votes
1
answer
1k
views
How can I access the output of a bazel rule from another rule without using a relative path?
I am attempting to use Bazel to compile a dhall program based on dhall-kubernetes to generate a Kubernetes YAML file.
The basic dhall compile without dhall-kubernetes using a simple bazel macro works ...
2
votes
1
answer
1k
views
Is it possible to get a kubernetes object in json or yaml with all optional fields explicitly set to null?
I'm attempting to migrate a helm/kubernetes codebase to dhall-kubernetes. Dhall is typed, so I need to provide full records with optional fields set to null if there were not set. So I'm looking for ...
10
votes
1
answer
1k
views
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 ...
1
vote
1
answer
363
views
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 : ...
2
votes
1
answer
504
views
How to merge a dynamically named record with a static one in Dhall?
I'm creating an AWS Step Function definition in Dhall. However, I don't know how to create a common structure they use for Choice states such as the example below:
{
"Not": {
"Variable": "...
3
votes
1
answer
251
views
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 ...
1
vote
1
answer
120
views
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",
"...
0
votes
1
answer
199
views
Dhall - map on record field
I have a type
let Resource = \(a : Type) ->
{ name : Text
, type : Text
, properties : a
}
and a function foo : InstanceTemplateProperties -> Properties.
I need to create a function ...
2
votes
2
answers
130
views
How to validate internal consistency of a config with dhall?
I will start with a motivating example of a config that almost represents an envoy proxy config :)
virtual_hosts:
- name: webxp-api_http
domains: ["*"]
routes:
- match: { prefix: "/static/v5.0" ...
1
vote
1
answer
139
views
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
:...
2
votes
1
answer
601
views
What is the dhall idiomatic way to associate different schemas to union values?
I'm trying to represent the pipeline system of the Zuul-CI project using Dhall types:
a pipeline can use different connections with different trigger events.
I'd like to provide a default pipeline ...
1
vote
1
answer
218
views
How to represent the following JSON in Dhall?
I am using the following JSON to represent our infrastructure. This is a greatly simplified version.
{
"us-east-1": {
"qa": {
"etcd": {}
}
},
"eu-central-1": {
"dev": {
"...
0
votes
2
answers
340
views
how to emulate Python join function in dhall?
I am new to dhall with no Haskell background. How do I convert a list of string to a single string with values separated by comma?
E.g.
["a", "b", "c"] -> "a,b,c"
I tried List/fold, but couldn't ...
1
vote
1
answer
103
views
Passing filename to read as a parameter
My configuration reads a certificate from a file.
This is a straightforward way:
in { devicesCa = "${/path/to/cert/ca.crt as Text}" }
I haven't found a way of passing /path/to/cert/ca.crt as a ...