Last active
September 4, 2021 19:43
-
-
Save JordanMartinez/fc8cfd89f0771a86d3a46882afec7849 to your computer and use it in GitHub Desktop.
Dhall Cheatsheet for Spago PR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Summary of https://hackage.haskell.org/package/dhall-1.40.1/docs/Dhall-Core.html#t:Expr | |
-- <dhall expression> -- haskell syntax | |
"text" -- TextLit (Chunks [] "text") | |
"an ${interpolatedValue} text" -- Text (Chunks [("an ", interpolatedValue)] " text") | |
["foo"] -- ListLit Nothing (Seq.singleton (TextLit [] "foo")) | |
[] : List Text -- ListLit (Just (App List Text)) Seq.empty | |
["foo"] # ["bar"] -- ListAppend fooExpr barExpr | |
["foo"] # ["bar"] # ["baz"] -- ListAppend (ListAppend fooExpr barExpr) bazExpr | |
{ key = "value" } -- RecordLit (Dhall.Map.singleton "key" (RecordField { recordFieldValue = "value", .. })) | |
recordExpr.keyName -- Field recordExpr (FieldSelection { fieldSelectionValue = "keyName", .. }) | |
recordExpr.key1.key2 -- Field (Field recordExpr key1Selector) key2Selector | |
{ key = "old" } // { key = "new", addedKey = "bar" } -- Prefer oldExpr newWithAddedExpr | |
{ key = "old" } with key = "new" -- With oldExpr ("key" :| []) newExpr | |
{ key1 = { key2 = "old" } with key1.key2 = "new" -- With oldExpr ("key1" :| ["key2"]) newExpr | |
let x = "foo" in x -- Let (Binding { variable = "x", value = fooExpr }) (Var (V "x" 0)) | |
let x = "A" let x = "B" in x -- Let (mkBinding "x" exprA) (Let (mkBinding "x" exprB) (Var (V "x" 0))) | |
./spago.dhall -- Embed importExpr | |
-- Not supported in Spago PR | |
λ(x : A) -> b -- Lam _ xBindingExpr bExpr | |
(λ(x : Text) -> [x]) "foo" -- App (Lam _ xExpr listExpr) fooExpr | |
if x then y else z -- BoolIf cond thenPath elsePath | |
recordExpr.{ key1, key2 } -- Project recordExpr (Left recordLitExpr) | |
-- not sure how to produce this... -- Project someExpr (Right [text]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment