-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Bricks is a lazy functional language based on Nix. -- -- Bricks is a lazy functional language based on Nix. This package -- provides parsing, rendering, and evaluation (forthcoming) for the -- Bricks language. @package bricks @version 0.0.0.2 module Bricks.Internal.Text -- | A space efficient, packed, unboxed Unicode text type. data Text :: * -- | O(n) all p t determines whether all -- characters in the Text t satisfy the predicate -- p. Subject to fusion. all :: (Char -> Bool) -> Text -> Bool concat :: Foldable f => f Text -> Text intercalate :: Foldable f => Text -> f Text -> Text -- | O(1) Tests whether a Text is empty or not. Subject to -- fusion. null :: Text -> Bool -- | O(n) Convert a String into a Text. Subject to -- fusion. Performs replacement on invalid scalar values. pack :: String -> Text -- | O(m+n) Replace every non-overlapping occurrence of -- needle in haystack with replacement. -- -- This function behaves as though it was defined as follows: -- --
--   replace needle replacement haystack =
--     intercalate replacement (splitOn needle haystack)
--   
-- -- As this suggests, each occurrence is replaced exactly once. So if -- needle occurs in replacement, that occurrence will -- not itself be replaced recursively: -- --
--   replace "oo" "foo" "oo" == "foo"
--   
-- -- In cases where several instances of needle overlap, only the -- first one will be replaced: -- --
--   replace "ofo" "bar" "ofofo" == "barfo"
--   
-- -- In (unlikely) bad cases, this function's time complexity degrades -- towards O(n*m). replace :: Text -> Text -> Text -> Text -- | O(n*m) replicate n t is a Text -- consisting of the input t repeated n times. replicate :: Int -> Text -> Text -- | O(1) Convert a character into a Text. Subject to fusion. -- Performs replacement on invalid scalar values. singleton :: Char -> Text -- | O(n) Convert a Text into a String. Subject to -- fusion. unpack :: Text -> String -- | O(n) Joins words using single space characters. unwords :: [Text] -> Text module Bricks.Internal.Seq -- | General-purpose finite sequences. data Seq a :: * -> * -- | O(1). Add an element to the left end of a sequence. Mnemonic: a -- triangle with the single element at the pointy end. (<|) :: a -> Seq a -> Seq a infixr 5 <| -- | O(1). Add an element to the right end of a sequence. Mnemonic: -- a triangle with the single element at the pointy end. (|>) :: Seq a -> a -> Seq a infixl 5 |> concat :: Foldable f => f (Seq a) -> Seq a -- | O(i) where i is the prefix length. dropWhileL -- p xs returns the suffix remaining after takeWhileL p -- xs. dropWhileL :: (a -> Bool) -> Seq a -> Seq a -- | O(i) where i is the suffix length. dropWhileR -- p xs returns the prefix remaining after takeWhileR p -- xs. -- -- dropWhileR p xs is equivalent to reverse -- (dropWhileL p (reverse xs)). dropWhileR :: (a -> Bool) -> Seq a -> Seq a -- | O(1). The empty sequence. empty :: Seq a -- | O(n). The filter function takes a predicate p -- and a sequence xs and returns a sequence of those elements -- which satisfy the predicate. filter :: (a -> Bool) -> Seq a -> Seq a -- | O(n). Create a sequence from a finite list of elements. There -- is a function toList in the opposite direction for all -- instances of the Foldable class, including Seq. fromList :: [a] -> Seq a intersperse :: a -> Seq a -> Seq a map :: (a -> b) -> Seq a -> Seq b minimum :: Ord a => Seq a -> Maybe a -- | O(1). Is this the empty sequence? null :: Seq a -> Bool -- | List of elements of a structure, from left to right. toList :: Foldable t => forall a. t a -> [a] -- | O(1). A singleton sequence. singleton :: a -> Seq a module Bricks.Internal.Prelude (<&>) :: Functor f => f a -> (a -> b) -> f b infixl 1 <&> module Bricks.Keyword data Keyword -- | All of the keywords. This list is used when parsing and rendering -- because an unquoted string cannot have a name that is exactly the same -- as a keyword. keywords :: [Keyword] keyword'rec :: Keyword keyword'let :: Keyword keyword'in :: Keyword keyword'with :: Keyword keyword'inherit :: Keyword keyword'inlineComment :: Keyword keywordString :: Keyword -> String keywordText :: Keyword -> Text module Bricks.UnquotedString -- | A string that can be rendered unquoted. Unquoted strings are -- restricted to a conservative set of characters; see -- str'canRenderUnquoted for the full rules. -- -- The constructor is tagged "unsafe" because it lets you construct and -- invalid value. Prefer str'tryUnquoted which does validate the -- text. newtype Str'Unquoted Str'Unquoted'Unsafe :: Text -> Str'Unquoted [str'unquotedToStatic] :: Str'Unquoted -> Text str'tryUnquoted :: Text -> Maybe Str'Unquoted -- | Throws an exception if the string cannot render unquoted. str'unquoted'orThrow :: Text -> Str'Unquoted -- | Whether a string having this name can be rendered without quoting it. -- We allow a string to render unquoted if all these conditions are met: -- -- -- --
--   >>> str'canRenderUnquoted "-ab_c"
--   True
--   
-- --
--   >>> str'canRenderUnquoted ""
--   False
--   
-- --
--   >>> str'canRenderUnquoted "a\"b"
--   False
--   
-- --
--   >>> str'canRenderUnquoted "let"
--   False
--   
str'canRenderUnquoted :: Text -> Bool -- | Letters, -, and _. char'canRenderUnquoted :: Char -> Bool instance GHC.Show.Show Bricks.UnquotedString.Str'Unquoted module Bricks.Expression data Expression -- | A variable, such as x. Expr'Var :: Str'Unquoted -> Expression -- | A string may be quoted either in the traditional form using a -- single double-quote ("..."): -- --
--   "one\ntwo"
--   
-- -- or in the "indented string" form using two single-quotes -- (''...''): -- --
--   ''
--     one
--     two
--   ''
--   
-- -- Both of these examples reduce to the same value, because leading -- whitespace is stripped from indented strings. -- -- Either may contain "antiquotation" (also known as "string -- interpolation") to conveniently concatenate string-valued variables -- into the string. -- --
--   "Hello, my name is ${name}!"
--   
-- -- Normal strings may contain the following escape sequences: -- -- -- -- The indented string form does not interpret any escape sequences. Expr'Str :: Str'Dynamic -> Expression -- | A list is an ordered collection of expressions. -- -- The empty list: -- --
--   [ ]
--   
-- -- A list containing three variables: -- --
--   [ a b c ]
--   
-- -- Lambdas, function applications, let-in expressions, -- and with expressions must be parenthesized when in a list. -- --
--   [
--     (x: f x y)
--     (g y)
--     (let a = y; in f a a)
--     (with d; f x a)
--   ]
--   
Expr'List :: List -> Expression -- | A dict is an unordered extensional mapping from strings. -- -- The empty dict (with no bindings): -- --
--   { }
--   
-- -- A dict with two bindings: -- --
--   {
--     a = "one";
--     b = "one two";
--   }
--   
-- -- By default, dict bindings cannot refer to each other. For that, you -- need the rec keyword to create a recursive dict. -- --
--   rec {
--     a = "one";
--     b = "${a} two";
--   }
--   
-- -- In either case, the order of the bindings does not matter. -- -- The left-hand side of a dict binding may be a quoted string (in the -- traditional "..." style, not the indented-string -- '' style), which make it possible for them to be strings that -- otherwise couldn't be expressed unquoted, such as strings containing -- spaces: -- --
--   { "a b" = "c"; }
--   
-- -- The left-hand side of a dict may even be an arbitrary expression, -- using the ${ ... } form: -- --
--   let x = "a b"; in { ${x} = "c"; }
--   
-- -- Dicts also support the inherit keyword: -- --
--   { inherit a; inherit (x) c d; }
--   
-- -- The previous expression is equivalent to: -- --
--   { a = a; c = x.c; d = x.d; }
--   
Expr'Dict :: Dict -> Expression -- | A dot expression (named after the . character it -- contains) looks up the value in a dict. -- -- The examples in this section all reduce to Z. -- --
--   { a = "Z"; }.a
--   
-- --
--   let x = { a = "Z"; }; in x.a
--   
-- --
--   { x = { a = "Z"; }; }.x.a
--   
-- -- The right-hand side of a dot may be a quoted string (in the -- traditional "..." style, not the indented-string -- '' style): -- --
--   { a = "Z"; }."a"
--   
-- -- The right-hand side of a dot may even be an arbitrary expression, -- using the ${ ... } form: -- --
--   { a = "Z"; }.${ let b = "a"; in b }
--   
Expr'Dot :: Dot -> Expression -- | A lambda expression x: y where x is the -- parameter. -- -- This is a function that turns a name into a greeting: -- --
--   name: "Hello, ${name}!"
--   
-- -- The function parameter can also be a dict pattern, which looks -- like this: -- --
--   { a, b, c ? "another" }: "Hello, ${a}, ${b}, and ${c}!"
--   
-- -- That function accepts a dict and looks up the keys a, -- b, and c from it, applying the default value -- "another" to c if it is not present in the dict. -- Dict patterns therefore give us something that resembles functions -- with named parameters and default arguments. -- -- By default, a lambda defined with a dict pattern fails to evaluate if -- the dict argument contains keys that are not listed in the pattern. To -- prevent it from failing, you can end the pattern with ...: -- --
--   ({ a, ... }: x) { a = "1"; b = "2"; }
--   
-- -- Every function has a single parameter. If you need multiple -- parameters, you have to curry: -- --
--   a: b: [ a b ]
--   
Expr'Lambda :: Lambda -> Expression -- | Function application: -- --
--   f x
--   
-- -- If a function has multiple (curried) parameters, you can chain them -- together like so: -- --
--   f x y z
--   
Expr'Apply :: Apply -> Expression -- | A let-in expression: -- --
--   let
--     greet = x: "Hello, ${x}!";
--     name = "Chris";
--   in
--     greet name
--   
-- -- Let bindings, like dict bindings, may also use the -- inherit keyword. -- --
--   let
--     d = { greet = x: "Hello, ${x}!"; name = "Chris"; }
--     inherit (d) greet name;
--   in
--     greet name
--   
-- -- The previous example also demonstrates how the bindings in a -- let expression may refer to each other (much like a dict with -- the rec keyword). As with dicts, the order of the bindings -- does not matter. Expr'Let :: Let -> Expression -- | A with expression is similar to a let-in -- expression, but the bindings come from a dict. -- --
--   with {
--     greet = x: "Hello, ${x}!";
--     name = "Chris";
--   };
--     greet name
--   
Expr'With :: With -> Expression -- | A fixed string value. We use the description "static" to mean the -- string may not contain antiquotation, in contrast with -- Str'Dynamic which can. type Str'Static = Text -- | A quoted string expression, which may be a simple string like -- "hello" or a more complex string containing antiquotation -- like "Hello, my name is ${name}!". See Expr'Str. -- -- We use the description "dynamic" to mean the string may contain -- antiquotation, in contrast with Str'Static which cannot. newtype Str'Dynamic Str'Dynamic :: Seq Str'1 -> Str'Dynamic [strDynamic'toSeq] :: Str'Dynamic -> Seq Str'1 -- | One part of a Str'Dynamic. data Str'1 Str'1'Literal :: Str'Static -> Str'1 Str'1'Antiquote :: Expression -> Str'1 strDynamic'toList :: Str'Dynamic -> [Str'1] strDynamic'fromList :: [Str'1] -> Str'Dynamic strDynamic'singleton :: Str'1 -> Str'Dynamic str'dynamicToStatic :: Str'Dynamic -> Maybe Str'Static str'staticToDynamic :: Str'Static -> Str'Dynamic str'unquotedToDynamic :: Str'Unquoted -> Str'Dynamic -- | A list literal expression, starting with [ and ending with -- ]. See Expr'List. newtype List List :: (Seq Expression) -> List -- | A dict literal expression, starting with { or rec { -- and ending with }. See Expr'Dict. data Dict Dict :: Bool -> Seq DictBinding -> Dict -- | Whether the dict is recursive (denoted by the rec keyword) [dict'rec] :: Dict -> Bool -- | The bindings (everything between { and }) [dict'bindings] :: Dict -> Seq DictBinding -- | A binding of the form x = y; within a DictLiteral or -- LetExpr. data DictBinding DictBinding'Eq :: Expression -> Expression -> DictBinding DictBinding'Inherit :: Inherit -> DictBinding -- | An expression of the form person.name that looks up a key -- from a dict. See Expr'Dot. data Dot Dot :: Expression -> Expression -> Dot [dot'dict] :: Dot -> Expression [dot'key] :: Dot -> Expression expression'applyDots :: Expression -> [Expression] -> Expression -- | A function expression. See Expr'Lambda. data Lambda Lambda :: Param -> Expression -> Lambda -- | Declaration of the function's parameter [lambda'head] :: Lambda -> Param -- | Body of the function; what it evaluates to [lambda'body] :: Lambda -> Expression -- | A parameter to a Lambda. All functions have a single parameter, -- but it's more complicated than that because it may also include dict -- destructuring. data Param -- | A simple single-parameter function Param'Name :: Str'Unquoted -> Param -- | Dict destructuring, which gives you something resembling multiple -- named parameters with default values Param'DictPattern :: DictPattern -> Param -- | Both a param name and a dict pattern, separated by the -- @ keyword Param'Both :: Str'Unquoted -> DictPattern -> Param -- | A type of function parameter (Param) that does dict -- destructuring. data DictPattern DictPattern :: Seq DictPattern'1 -> Bool -> DictPattern -- | The list of keys to pull out of the dict, along with any default value -- each may have [dictPattern'items] :: DictPattern -> Seq DictPattern'1 -- | Whether to allow additional keys beyond what is listed in the items, -- corresponding to the ... keyword [dictPattern'ellipsis] :: DictPattern -> Bool -- | One item within a DictPattern. data DictPattern'1 DictPattern'1 :: Str'Unquoted -> Maybe Expression -> DictPattern'1 -- | The name of the key to pull out of the dict [dictPattern'1'name] :: DictPattern'1 -> Str'Unquoted -- | The default value to be used if the key is not present in the dict [dictPattern'1'default] :: DictPattern'1 -> Maybe Expression -- | A function application expression. See Expr'Apply. data Apply Apply :: Expression -> Expression -> Apply -- | The function being called [apply'func] :: Apply -> Expression -- | The argument to the function [apply'arg] :: Apply -> Expression expression'applyArgs :: Expression -> [Expression] -> Expression -- | A let-in expression. See Expr'Let. data Let Let :: Seq LetBinding -> Expression -> Let -- | The bindings (everything between the let and in -- keywords) [let'bindings] :: Let -> Seq LetBinding -- | The value (everything after the in keyword) [let'value] :: Let -> Expression -- | A semicolon-terminated binding within the binding list of a Let -- expression. data LetBinding -- | A binding with an equals sign, of the form x = y; LetBinding'Eq :: Str'Static -> Expression -> LetBinding -- | A binding using the inherit keyword, of the form inherit -- a b; or inherit (x) a b; LetBinding'Inherit :: Inherit -> LetBinding -- | A with expression. See Expr'With. data With With :: Expression -> Expression -> With [with'context] :: With -> Expression [with'value] :: With -> Expression data Inherit Inherit :: Maybe Expression -> Seq Str'Static -> Inherit [inherit'source] :: Inherit -> Maybe Expression [inherit'names] :: Inherit -> Seq Str'Static instance Data.Semigroup.Semigroup Bricks.Expression.Str'Dynamic instance GHC.Base.Monoid Bricks.Expression.Str'Dynamic instance Data.Semigroup.Semigroup Bricks.Expression.List instance GHC.Base.Monoid Bricks.Expression.List instance GHC.Show.Show Bricks.Expression.Expression instance GHC.Show.Show Bricks.Expression.Str'Dynamic instance GHC.Show.Show Bricks.Expression.Str'1 instance GHC.Show.Show Bricks.Expression.List instance GHC.Show.Show Bricks.Expression.Dict instance GHC.Show.Show Bricks.Expression.DictBinding instance GHC.Show.Show Bricks.Expression.Dot instance GHC.Show.Show Bricks.Expression.Lambda instance GHC.Show.Show Bricks.Expression.Param instance GHC.Show.Show Bricks.Expression.DictPattern instance GHC.Show.Show Bricks.Expression.DictPattern'1 instance GHC.Show.Show Bricks.Expression.Apply instance GHC.Show.Show Bricks.Expression.Let instance GHC.Show.Show Bricks.Expression.LetBinding instance GHC.Show.Show Bricks.Expression.With instance GHC.Show.Show Bricks.Expression.Inherit instance Bricks.Expression.Show' Bricks.Expression.Expression instance Bricks.Expression.Show' Bricks.Expression.Str'Dynamic instance Bricks.Expression.Show' Bricks.Expression.Str'1 instance Bricks.Expression.Show' Bricks.Expression.List instance Bricks.Expression.Show' Bricks.Expression.Dict instance Bricks.Expression.Show' Bricks.Expression.DictBinding instance Bricks.Expression.Show' Bricks.Expression.Dot instance Bricks.Expression.Show' Bricks.Expression.Lambda instance Bricks.Expression.Show' Bricks.Expression.Param instance Bricks.Expression.Show' Bricks.Expression.DictPattern instance Bricks.Expression.Show' Bricks.Expression.DictPattern'1 instance Bricks.Expression.Show' Bricks.Expression.Apply instance Bricks.Expression.Show' Bricks.Expression.Let instance Bricks.Expression.Show' Bricks.Expression.LetBinding instance Bricks.Expression.Show' Bricks.Expression.With instance Bricks.Expression.Show' Bricks.Expression.Inherit -- | Functions for constructing Expressions that match the -- Show implementations. -- -- This module is only designed for testing and REPL use. It isn't -- re-exported into the main Bricks API because it's a bit messy: -- -- module Bricks.Expression.Construction lambda :: Param'Builder -> Expression -> Expression apply :: Expression -> Expression -> Expression var :: Text -> Expression dot :: Expression -> Expression -> Expression let'in :: [LetBinding] -> Expression -> Expression dict :: [DictBinding] -> Expression rec'dict :: [DictBinding] -> Expression class Binding a b | b -> a binding :: Binding a b => a -> Expression -> b class IsInherit a fromInherit :: IsInherit a => Inherit -> a inherit :: IsInherit a => [Text] -> a inherit'from :: IsInherit a => Expression -> [Text] -> a str :: [Str'1'] -> Expression antiquote :: Expression -> Str'1' -- | A newtype for Str'1 just so we can give it the IsString -- instance which would be dubiously appropriate for the actual -- Str'1 type. newtype Str'1' Str'1' :: Str'1 -> Str'1' [unStr'1'] :: Str'1' -> Str'1 class IsParam a param :: IsParam a => Text -> a newtype Param'Builder Param'Builder :: (NonEmpty Param) -> Param'Builder buildParam :: Param'Builder -> Param paramBuilder :: Param -> Param'Builder pattern :: [DictPattern'1] -> Param'Builder def :: Expression -> DictPattern'1 -> DictPattern'1 ellipsis :: Param'Builder -- | Combine two params, merging dict patterns with -- mergeDictPatterns and preferring the right-hand-side when names -- conflict. mergeParams :: Param -> Param -> Param -- | Combine two dict patterns, taking the concatenation of the item list, -- and the Boolean or of the ellipsis flag. mergeDictPatterns :: DictPattern -> DictPattern -> DictPattern instance Data.Semigroup.Semigroup Bricks.Expression.Construction.Param'Builder instance Bricks.Expression.Construction.Binding Bricks.Expression.Expression Bricks.Expression.DictBinding instance Bricks.Expression.Construction.Binding Data.Text.Internal.Text Bricks.Expression.LetBinding instance Bricks.Expression.Construction.IsInherit Bricks.Expression.DictBinding instance Bricks.Expression.Construction.IsInherit Bricks.Expression.LetBinding instance Data.String.IsString Bricks.Expression.Construction.Str'1' instance Bricks.Expression.Construction.IsParam Bricks.Expression.Construction.Param'Builder instance Bricks.Expression.Construction.IsParam Bricks.Expression.DictPattern'1 module Bricks.IndentedString -- | An "indented string literal," delimited by two single-quotes -- ''. -- -- This type of literal is called "indented" because the parser -- automatically removes leading whitespace from the string -- (inStr'dedent), which makes it convenient to use these literals -- for multi-line strings within an indented expression without the -- whitespace from indentation ending up as part of the string. newtype InStr InStr :: Seq InStr'1 -> InStr [inStr'toSeq] :: InStr -> Seq InStr'1 -- | Join InStrs with newlines interspersed. inStr'join :: InStr -> Str'Dynamic -- | Determine how many characters of whitespace to strip from an indented -- string. inStr'level :: InStr -> Natural -- | Determine the minimum indentation of any nonempty line, and remove -- that many space characters from the front of every line. inStr'dedent :: InStr -> InStr -- | Remove any empty lines from the beginning or end of an indented -- string. inStr'trim :: InStr -> InStr inStr'toList :: InStr -> [InStr'1] -- | One line of an InStr. data InStr'1 InStr'1 :: Natural -> Str'Dynamic -> InStr'1 -- | The number of leading space characters. We store this separately for -- easier implementation of inStr'dedent. [inStr'1'level] :: InStr'1 -> Natural -- | The rest of the line after any leading spaces. [inStr'1'str] :: InStr'1 -> Str'Dynamic -- | Determines whether an InStr'1 contains any non-space -- characters. The opposite of inStr'1'nonEmpty. -- -- This is used to determine whether this line should be considered when -- calculating the number of space characters to strip in -- inStr'dedent. inStr'1'nonEmpty :: InStr'1 -> Bool -- | The opposite of inStr'1'nonEmpty. inStr'1'empty :: InStr'1 -> Bool -- | Modify an InStr by applying a function to its number of leading -- spaces. inStr'1'modifyLevel :: (Natural -> Natural) -> (InStr'1 -> InStr'1) instance Data.Semigroup.Semigroup Bricks.IndentedString.InStr instance GHC.Base.Monoid Bricks.IndentedString.InStr instance GHC.Show.Show Bricks.IndentedString.InStr instance GHC.Show.Show Bricks.IndentedString.InStr'1 -- | Parsec Parsers for the Bricks language. -- -- Most parsers consume trailing whitespace, except ones that operate -- within quoted string environments where whitespace is significant. module Bricks.Parsing -- | The primary, top-level expression parser. This is what you use to -- parse a .nix file. -- --
--   >>> parseTest parse'expression ""
--   parse error at (line 1, column 1):
--   unexpected end of input
--   expecting expression
--   
parse'expression :: Parser Expression -- | Parser for a parenthesized expression, from opening parenthesis to -- closing parenthesis. parse'expression'paren :: Parser Expression -- | Parser for an expression in a context that is expecting a dict key. -- -- One of: -- -- parse'expression'dictKey :: Parser Expression -- | Parser for a list of expressions in a list literal ([ x y z -- ]) or in a chain of function arguments (f x y z). -- --
--   >>> parseTest parse'expressionList ""
--   []
--   
-- --
--   >>> parseTest (length <$> parse'expressionList) "x \"one two\" (a: b) (c d)"
--   4
--   
-- --
--   >>> parseTest (length <$> parse'expressionList) "(x \"one two\" (a: b) (c d))"
--   1
--   
parse'expressionList :: Parser [Expression] -- | Parser for a single item within an expression list -- (expressionListP). This expression is not a lambda, a -- function application, a let-in expression, or a -- with expression. -- --
--   >>> parseTest parse'expressionList'1 "ab.xy"
--   dot (var "ab") (str ["xy"])
--   
-- --
--   >>> parseTest parse'expressionList'1 "(x: f x x) y z"
--   lambda (param "x") (apply (apply (var "f") (var "x")) (var "x"))
--   
-- --
--   >>> parseTest parse'expressionList'1 "{ a = b; }.a y"
--   dot (dict [binding (str ["a"]) (var "b")]) (str ["a"])
--   
parse'expressionList'1 :: Parser Expression -- | Like parse'expressionList'1, but with the further restriction -- that the expression may not be a Dot. -- --
--   >>> parseTest parse'expressionList'1'noDot "ab.xy"
--   var "ab"
--   
-- --
--   >>> parseTest parse'expressionList'1'noDot "(x: f x x) y z"
--   lambda (param "x") (apply (apply (var "f") (var "x")) (var "x"))
--   
-- --
--   >>> parseTest parse'expressionList'1'noDot "{ a = b; }.a y"
--   dict [binding (str ["a"]) (var "b")]
--   
parse'expressionList'1'noDot :: Parser Expression -- | Parser for an unquoted string. Unquoted strings are restricted to a -- conservative set of characters, and they may not be any of the -- keywords. -- --
--   >>> parseTest parse'strUnquoted "abc"
--   unquoted "abc"
--   
-- --
--   >>> parseTest parse'strUnquoted "x{y"
--   unquoted "x"
--   
-- --
--   >>> parseTest parse'strUnquoted "let"
--   parse error at (line 1, column 4):
--   unexpected end of input
--   
parse'strUnquoted :: Parser Str'Unquoted -- | Parser for a static string which may be either quoted or unquoted. -- --
--   >>> parseTest parse'strStatic "\"hello\""
--   "hello"
--   
-- --
--   >>> parseTest parse'strStatic "hello"
--   "hello"
--   
-- --
--   >>> parseTest parse'strStatic "\"a b\""
--   "a b"
--   
-- --
--   >>> parseTest parse'strStatic "a b"
--   "a"
--   
-- -- By "static," we mean that the string may not contain -- antiquotation. -- --
--   >>> parseTest parse'strStatic "\"a${x}b\" xyz"
--   parse error at (line 1, column 5):
--   antiquotation is not allowed in this context
--   
parse'strStatic :: Parser Str'Static -- | Parser for a static string that is quoted. parse'strStatic'quoted :: Parser Str'Static -- | Parser for an unquoted static string. parse'strStatic'unquoted :: Parser Str'Static -- | Parser for a dynamic string that is quoted. It may be a "normal" -- quoted string delimited by one double-quote "..." -- (parse'strDynamic'normalQ) or an "indented" string delimited by -- two single-quotes ''...'' -- (parse'strDynamic'indentedQ). parse'strDynamic'quoted :: Parser Str'Dynamic -- | Parser for a dynamic string enclosed in "normal" quotes -- ("..."). parse'strDynamic'normalQ :: Parser Str'Dynamic -- | Parser for a dynamic string enclosed in "indented string" format, -- delimited by two single-quotes ''...''. This form of -- string does not have any escape sequences. parse'strDynamic'indentedQ :: Parser Str'Dynamic -- | Parser for at least one normal character, within a normally-quoted -- string context, up to but not including the end of the string or the -- start of an antiquotation. parse'str'within'normalQ :: Parser Text parse'str'escape'normalQ :: Parser Text -- | Parser for an indented string. This parser produces a representation -- of the lines from the source as-is, before the whitespace is cleaned -- up. parse'inStr :: Parser InStr -- | Parser for a single line of an InStr. parse'inStr'1 :: Parser InStr'1 -- | Parser for a list expression ([ ... ]). -- --
--   >>> parseTest parse'list "[]"
--   list []
--   
-- --
--   >>> parseTest parse'list "[x \"one\" (a: b) (c d)]"
--   list [var "x", str ["one"], lambda (param "a") (var "b"), apply (var "c") (var "d")]
--   
parse'list :: Parser List -- | Parser for a dict expression, either recursive (rec keyword) -- or not. -- --
--   >>> parseTest parse'dict "{}"
--   dict []
--   
-- --
--   >>> parseTest parse'dict "rec {  }"
--   rec'dict []
--   
-- --
--   >>> parseTest parse'dict "{ a = b; inherit (x) y z \"s t\"; }"
--   dict [binding (str ["a"]) (var "b"), inherit'from (var "x") ["y", "z", "s t"]]
--   
parse'dict :: Parser Dict -- | Parser for a recursive (rec keyword) dict. -- --
--   >>> parseTest parse'dict "rec {  }"
--   rec'dict []
--   
-- --
--   >>> parseTest parse'dict "rec { a = \"1\"; b = \"${a}2\"; }"
--   rec'dict [binding (str ["a"]) (str ["1"]), binding (str ["b"]) (str [antiquote (var "a"), "2"])]
--   
parse'dict'rec :: Parser (Seq DictBinding) -- | Parser for a non-recursive (no rec keyword) dict. -- --
--   >>> parseTest parse'dict "{  }"
--   dict []
--   
-- --
--   >>> parseTest parse'dict "{ a = \"1\"; b = \"${a}2\"; }"
--   dict [binding (str ["a"]) (str ["1"]), binding (str ["b"]) (str [antiquote (var "a"), "2"])]
--   
parse'dict'noRec :: Parser (Seq DictBinding) parse'dictBinding :: Parser DictBinding parse'dictBinding'inherit :: Parser DictBinding parse'dictBinding'eq :: Parser DictBinding -- | Parser for a chain of dict lookups (like .a.b.c) on the -- right-hand side of a Dot expression. -- --
--   >>> parseTest parse'dot'rhs'chain ""
--   []
--   
-- --
--   >>> parseTest parse'dot'rhs'chain ".abc"
--   [str ["abc"]]
--   
-- --
--   >>> parseTest parse'dot'rhs'chain ".a.${b}.\"c\".\"d${e}\""
--   [str ["a"],var "b",str ["c"],str ["d", antiquote (var "e")]]
--   
parse'dot'rhs'chain :: Parser [Expression] -- | Parser for a lambda expression (x: y). -- --
--   >>> parseTest parse'lambda "x: [x x \"a\"]"
--   lambda (param "x") (list [var "x", var "x", str ["a"]])
--   
-- --
--   >>> parseTest parse'lambda "{a,b}:a"
--   lambda (pattern [param "a", param "b"]) (var "a")
--   
-- --
--   >>> parseTest parse'lambda "{ ... }: \"x\""
--   lambda (pattern [] <> ellipsis) (str ["x"])
--   
-- --
--   >>> parseTest parse'lambda "a@{ f, b ? g x, ... }: f b"
--   lambda (param "a" <> pattern [param "f", param "b" & def (apply (var "g") (var "x"))] <> ellipsis) (apply (var "f") (var "b"))
--   
-- --
--   >>> parseTest parse'lambda "a: b: \"x\""
--   lambda (param "a") (lambda (param "b") (str ["x"]))
--   
parse'lambda :: Parser Lambda -- | Parser for a function parameter (the beginning of a Lambda), -- including the colon. This forms part of parse'expression, so it -- backtracks in places where it has overlap with other types of -- expressions. parse'param :: Parser Param -- | Parser for a parameter that starts with a variable. This could be a -- simple param that consists only of only the variable, or the -- variable may be followed by a dict pattern. parse'param'var :: Parser Param -- | Parser for a param that has no variable, only a a dict pattern. This -- parser backtracks because the beginning of a dict pattern looks like -- the beginning of a dict expression. parse'param'noVar :: Parser Param -- | Parser for a dict pattern (the type of lambda parameter that does dict -- destructuring. This parser does not backtrack. parse'dictPattern :: Parser DictPattern -- | This is used in a lookahead by parse'param to determine whether -- we're about to start parsing a DictPattern. parse'dictPattern'start :: Parser () parse'let :: Parser Let parse'letBinding :: Parser LetBinding parse'letBinding'eq :: Parser LetBinding parse'letBinding'inherit :: Parser LetBinding parse'with :: Parser With parse'inherit :: Parser Inherit parse'spaces :: Parser () parse'comment :: Parser () parse'comment'inline :: Parser () parse'comment'block :: Parser () -- | Backtracking parser for a particular keyword. parse'keyword :: Keyword -> Parser () parse'antiquote :: Parser Str'Dynamic module Bricks.Rendering type Render a = a -> Text -- | Render an expression. render'expression :: Render Expression -- | Render an expression in a list context. render'expression'listContext :: Render Expression -- | Render an expression in the context of the left-hand side of a -- Dot. render'expression'dotLeftContext :: Render Expression -- | Render an expression in the context of the left-hand side of an -- Apply. render'expression'applyLeftContext :: Render Expression -- | Render an expression in the context of the right-hand side of an -- Apply. render'expression'applyRightContext :: Render Expression render'expression'inParens :: Render Expression render'expression'dictKey :: Render Expression -- | Insert escape sequences for rendering normal double-quoted -- (") strings. str'escape :: Text -> Text -- | Render an unquoted string in unquoted form. render'strUnquoted :: Render Str'Unquoted -- | Render a static string, in unquoted form if possible. render'strStatic'unquotedIfPossible :: Render Str'Static -- | Render a static string, in quoted form. render'strStatic'quoted :: Render Str'Static -- | Render a dynamic string, in unquoted form if possible. render'strDynamic'unquotedIfPossible :: Render Str'Dynamic -- | Render a dynamic string, in quoted form. render'strDynamic'quoted :: Render Str'Dynamic -- | Render one line of an indented string (InStr). render'inStr'1 :: Render InStr'1 -- | Render a list literal ([ ... ]). render'list :: Render List -- | Render a dict literal ({ ... }). render'dict :: Render Dict -- | Render a binding within a Dict, without the trailing semicolon. render'dictBinding :: Render DictBinding -- | Render a dot expression (a.b). render'dot :: Render Dot -- | Render a lambda expression (x: y). render'lambda :: Render Lambda -- | Render a lambda parameter: everything from the beginning of a lambda, -- up to but not including the : that separates the head from -- the body of the lambda. render'param :: Render Param -- | Render a dict pattern ({ a, b ? c, ... }). render'dictPattern :: Render DictPattern -- | Render a single item in a DictPattern. render'dictPattern'1 :: Render DictPattern'1 -- | Render a function application expression (f x). render'apply :: Render Apply -- | Render a let-in expression. render'let :: Render Let -- | Render a binding within a Let, without the trailing semicolon. render'letBinding :: Render LetBinding -- | Render a with expression. render'with :: Render With render'inherit :: Render Inherit -- | Bricks is a lazy functional language that strongly resembles -- Nix. -- -- Notable differences from Nix: -- -- -- -- The following modules are re-exported from this module in their -- entireties: -- -- -- -- Other modules: -- -- module Bricks data Expression -- | A variable, such as x. Expr'Var :: Str'Unquoted -> Expression -- | A string may be quoted either in the traditional form using a -- single double-quote ("..."): -- --
--   "one\ntwo"
--   
-- -- or in the "indented string" form using two single-quotes -- (''...''): -- --
--   ''
--     one
--     two
--   ''
--   
-- -- Both of these examples reduce to the same value, because leading -- whitespace is stripped from indented strings. -- -- Either may contain "antiquotation" (also known as "string -- interpolation") to conveniently concatenate string-valued variables -- into the string. -- --
--   "Hello, my name is ${name}!"
--   
-- -- Normal strings may contain the following escape sequences: -- -- -- -- The indented string form does not interpret any escape sequences. Expr'Str :: Str'Dynamic -> Expression -- | A list is an ordered collection of expressions. -- -- The empty list: -- --
--   [ ]
--   
-- -- A list containing three variables: -- --
--   [ a b c ]
--   
-- -- Lambdas, function applications, let-in expressions, -- and with expressions must be parenthesized when in a list. -- --
--   [
--     (x: f x y)
--     (g y)
--     (let a = y; in f a a)
--     (with d; f x a)
--   ]
--   
Expr'List :: List -> Expression -- | A dict is an unordered extensional mapping from strings. -- -- The empty dict (with no bindings): -- --
--   { }
--   
-- -- A dict with two bindings: -- --
--   {
--     a = "one";
--     b = "one two";
--   }
--   
-- -- By default, dict bindings cannot refer to each other. For that, you -- need the rec keyword to create a recursive dict. -- --
--   rec {
--     a = "one";
--     b = "${a} two";
--   }
--   
-- -- In either case, the order of the bindings does not matter. -- -- The left-hand side of a dict binding may be a quoted string (in the -- traditional "..." style, not the indented-string -- '' style), which make it possible for them to be strings that -- otherwise couldn't be expressed unquoted, such as strings containing -- spaces: -- --
--   { "a b" = "c"; }
--   
-- -- The left-hand side of a dict may even be an arbitrary expression, -- using the ${ ... } form: -- --
--   let x = "a b"; in { ${x} = "c"; }
--   
-- -- Dicts also support the inherit keyword: -- --
--   { inherit a; inherit (x) c d; }
--   
-- -- The previous expression is equivalent to: -- --
--   { a = a; c = x.c; d = x.d; }
--   
Expr'Dict :: Dict -> Expression -- | A dot expression (named after the . character it -- contains) looks up the value in a dict. -- -- The examples in this section all reduce to Z. -- --
--   { a = "Z"; }.a
--   
-- --
--   let x = { a = "Z"; }; in x.a
--   
-- --
--   { x = { a = "Z"; }; }.x.a
--   
-- -- The right-hand side of a dot may be a quoted string (in the -- traditional "..." style, not the indented-string -- '' style): -- --
--   { a = "Z"; }."a"
--   
-- -- The right-hand side of a dot may even be an arbitrary expression, -- using the ${ ... } form: -- --
--   { a = "Z"; }.${ let b = "a"; in b }
--   
Expr'Dot :: Dot -> Expression -- | A lambda expression x: y where x is the -- parameter. -- -- This is a function that turns a name into a greeting: -- --
--   name: "Hello, ${name}!"
--   
-- -- The function parameter can also be a dict pattern, which looks -- like this: -- --
--   { a, b, c ? "another" }: "Hello, ${a}, ${b}, and ${c}!"
--   
-- -- That function accepts a dict and looks up the keys a, -- b, and c from it, applying the default value -- "another" to c if it is not present in the dict. -- Dict patterns therefore give us something that resembles functions -- with named parameters and default arguments. -- -- By default, a lambda defined with a dict pattern fails to evaluate if -- the dict argument contains keys that are not listed in the pattern. To -- prevent it from failing, you can end the pattern with ...: -- --
--   ({ a, ... }: x) { a = "1"; b = "2"; }
--   
-- -- Every function has a single parameter. If you need multiple -- parameters, you have to curry: -- --
--   a: b: [ a b ]
--   
Expr'Lambda :: Lambda -> Expression -- | Function application: -- --
--   f x
--   
-- -- If a function has multiple (curried) parameters, you can chain them -- together like so: -- --
--   f x y z
--   
Expr'Apply :: Apply -> Expression -- | A let-in expression: -- --
--   let
--     greet = x: "Hello, ${x}!";
--     name = "Chris";
--   in
--     greet name
--   
-- -- Let bindings, like dict bindings, may also use the -- inherit keyword. -- --
--   let
--     d = { greet = x: "Hello, ${x}!"; name = "Chris"; }
--     inherit (d) greet name;
--   in
--     greet name
--   
-- -- The previous example also demonstrates how the bindings in a -- let expression may refer to each other (much like a dict with -- the rec keyword). As with dicts, the order of the bindings -- does not matter. Expr'Let :: Let -> Expression -- | A with expression is similar to a let-in -- expression, but the bindings come from a dict. -- --
--   with {
--     greet = x: "Hello, ${x}!";
--     name = "Chris";
--   };
--     greet name
--   
Expr'With :: With -> Expression -- | Render an expression. render'expression :: Render Expression -- | Render an expression in a list context. render'expression'listContext :: Render Expression -- | Render an expression in the context of the left-hand side of a -- Dot. render'expression'dotLeftContext :: Render Expression -- | Render an expression in the context of the left-hand side of an -- Apply. render'expression'applyLeftContext :: Render Expression -- | Render an expression in the context of the right-hand side of an -- Apply. render'expression'applyRightContext :: Render Expression render'expression'inParens :: Render Expression render'expression'dictKey :: Render Expression -- | The primary, top-level expression parser. This is what you use to -- parse a .nix file. -- --
--   >>> parseTest parse'expression ""
--   parse error at (line 1, column 1):
--   unexpected end of input
--   expecting expression
--   
parse'expression :: Parser Expression -- | Parser for a parenthesized expression, from opening parenthesis to -- closing parenthesis. parse'expression'paren :: Parser Expression -- | Parser for an expression in a context that is expecting a dict key. -- -- One of: -- -- parse'expression'dictKey :: Parser Expression -- | Parser for a list of expressions in a list literal ([ x y z -- ]) or in a chain of function arguments (f x y z). -- --
--   >>> parseTest parse'expressionList ""
--   []
--   
-- --
--   >>> parseTest (length <$> parse'expressionList) "x \"one two\" (a: b) (c d)"
--   4
--   
-- --
--   >>> parseTest (length <$> parse'expressionList) "(x \"one two\" (a: b) (c d))"
--   1
--   
parse'expressionList :: Parser [Expression] -- | Parser for a single item within an expression list -- (expressionListP). This expression is not a lambda, a -- function application, a let-in expression, or a -- with expression. -- --
--   >>> parseTest parse'expressionList'1 "ab.xy"
--   dot (var "ab") (str ["xy"])
--   
-- --
--   >>> parseTest parse'expressionList'1 "(x: f x x) y z"
--   lambda (param "x") (apply (apply (var "f") (var "x")) (var "x"))
--   
-- --
--   >>> parseTest parse'expressionList'1 "{ a = b; }.a y"
--   dot (dict [binding (str ["a"]) (var "b")]) (str ["a"])
--   
parse'expressionList'1 :: Parser Expression -- | Like parse'expressionList'1, but with the further restriction -- that the expression may not be a Dot. -- --
--   >>> parseTest parse'expressionList'1'noDot "ab.xy"
--   var "ab"
--   
-- --
--   >>> parseTest parse'expressionList'1'noDot "(x: f x x) y z"
--   lambda (param "x") (apply (apply (var "f") (var "x")) (var "x"))
--   
-- --
--   >>> parseTest parse'expressionList'1'noDot "{ a = b; }.a y"
--   dict [binding (str ["a"]) (var "b")]
--   
parse'expressionList'1'noDot :: Parser Expression -- | Insert escape sequences for rendering normal double-quoted -- (") strings. str'escape :: Text -> Text -- | Parser for at least one normal character, within a normally-quoted -- string context, up to but not including the end of the string or the -- start of an antiquotation. parse'str'within'normalQ :: Parser Text parse'str'escape'normalQ :: Parser Text -- | A fixed string value. We use the description "static" to mean the -- string may not contain antiquotation, in contrast with -- Str'Dynamic which can. type Str'Static = Text -- | Render a static string, in unquoted form if possible. render'strStatic'unquotedIfPossible :: Render Str'Static -- | Render a static string, in quoted form. render'strStatic'quoted :: Render Str'Static -- | Parser for a static string which may be either quoted or unquoted. -- --
--   >>> parseTest parse'strStatic "\"hello\""
--   "hello"
--   
-- --
--   >>> parseTest parse'strStatic "hello"
--   "hello"
--   
-- --
--   >>> parseTest parse'strStatic "\"a b\""
--   "a b"
--   
-- --
--   >>> parseTest parse'strStatic "a b"
--   "a"
--   
-- -- By "static," we mean that the string may not contain -- antiquotation. -- --
--   >>> parseTest parse'strStatic "\"a${x}b\" xyz"
--   parse error at (line 1, column 5):
--   antiquotation is not allowed in this context
--   
parse'strStatic :: Parser Str'Static -- | Parser for a static string that is quoted. parse'strStatic'quoted :: Parser Str'Static -- | Parser for an unquoted static string. parse'strStatic'unquoted :: Parser Str'Static -- | A quoted string expression, which may be a simple string like -- "hello" or a more complex string containing antiquotation -- like "Hello, my name is ${name}!". See Expr'Str. -- -- We use the description "dynamic" to mean the string may contain -- antiquotation, in contrast with Str'Static which cannot. newtype Str'Dynamic Str'Dynamic :: Seq Str'1 -> Str'Dynamic [strDynamic'toSeq] :: Str'Dynamic -> Seq Str'1 -- | One part of a Str'Dynamic. data Str'1 Str'1'Literal :: Str'Static -> Str'1 Str'1'Antiquote :: Expression -> Str'1 strDynamic'toList :: Str'Dynamic -> [Str'1] strDynamic'fromList :: [Str'1] -> Str'Dynamic strDynamic'singleton :: Str'1 -> Str'Dynamic -- | Render a dynamic string, in unquoted form if possible. render'strDynamic'unquotedIfPossible :: Render Str'Dynamic -- | Render a dynamic string, in quoted form. render'strDynamic'quoted :: Render Str'Dynamic -- | Parser for a dynamic string that is quoted. It may be a "normal" -- quoted string delimited by one double-quote "..." -- (parse'strDynamic'normalQ) or an "indented" string delimited by -- two single-quotes ''...'' -- (parse'strDynamic'indentedQ). parse'strDynamic'quoted :: Parser Str'Dynamic -- | Parser for a dynamic string enclosed in "normal" quotes -- ("..."). parse'strDynamic'normalQ :: Parser Str'Dynamic -- | Parser for a dynamic string enclosed in "indented string" format, -- delimited by two single-quotes ''...''. This form of -- string does not have any escape sequences. parse'strDynamic'indentedQ :: Parser Str'Dynamic -- | A string that can be rendered unquoted. Unquoted strings are -- restricted to a conservative set of characters; see -- str'canRenderUnquoted for the full rules. -- -- The constructor is tagged "unsafe" because it lets you construct and -- invalid value. Prefer str'tryUnquoted which does validate the -- text. newtype Str'Unquoted Str'Unquoted'Unsafe :: Text -> Str'Unquoted [str'unquotedToStatic] :: Str'Unquoted -> Text str'tryUnquoted :: Text -> Maybe Str'Unquoted -- | Throws an exception if the string cannot render unquoted. str'unquoted'orThrow :: Text -> Str'Unquoted -- | Whether a string having this name can be rendered without quoting it. -- We allow a string to render unquoted if all these conditions are met: -- -- -- --
--   >>> str'canRenderUnquoted "-ab_c"
--   True
--   
-- --
--   >>> str'canRenderUnquoted ""
--   False
--   
-- --
--   >>> str'canRenderUnquoted "a\"b"
--   False
--   
-- --
--   >>> str'canRenderUnquoted "let"
--   False
--   
str'canRenderUnquoted :: Text -> Bool -- | Letters, -, and _. char'canRenderUnquoted :: Char -> Bool -- | Render an unquoted string in unquoted form. render'strUnquoted :: Render Str'Unquoted -- | Parser for an unquoted string. Unquoted strings are restricted to a -- conservative set of characters, and they may not be any of the -- keywords. -- --
--   >>> parseTest parse'strUnquoted "abc"
--   unquoted "abc"
--   
-- --
--   >>> parseTest parse'strUnquoted "x{y"
--   unquoted "x"
--   
-- --
--   >>> parseTest parse'strUnquoted "let"
--   parse error at (line 1, column 4):
--   unexpected end of input
--   
parse'strUnquoted :: Parser Str'Unquoted str'dynamicToStatic :: Str'Dynamic -> Maybe Str'Static str'staticToDynamic :: Str'Static -> Str'Dynamic str'unquotedToDynamic :: Str'Unquoted -> Str'Dynamic -- | An "indented string literal," delimited by two single-quotes -- ''. -- -- This type of literal is called "indented" because the parser -- automatically removes leading whitespace from the string -- (inStr'dedent), which makes it convenient to use these literals -- for multi-line strings within an indented expression without the -- whitespace from indentation ending up as part of the string. newtype InStr InStr :: Seq InStr'1 -> InStr [inStr'toSeq] :: InStr -> Seq InStr'1 inStr'toList :: InStr -> [InStr'1] -- | Join InStrs with newlines interspersed. inStr'join :: InStr -> Str'Dynamic -- | Determine how many characters of whitespace to strip from an indented -- string. inStr'level :: InStr -> Natural -- | Determine the minimum indentation of any nonempty line, and remove -- that many space characters from the front of every line. inStr'dedent :: InStr -> InStr -- | Remove any empty lines from the beginning or end of an indented -- string. inStr'trim :: InStr -> InStr -- | Render one line of an indented string (InStr). render'inStr'1 :: Render InStr'1 -- | Parser for an indented string. This parser produces a representation -- of the lines from the source as-is, before the whitespace is cleaned -- up. parse'inStr :: Parser InStr -- | Parser for a single line of an InStr. parse'inStr'1 :: Parser InStr'1 -- | One line of an InStr. data InStr'1 InStr'1 :: Natural -> Str'Dynamic -> InStr'1 -- | The number of leading space characters. We store this separately for -- easier implementation of inStr'dedent. [inStr'1'level] :: InStr'1 -> Natural -- | The rest of the line after any leading spaces. [inStr'1'str] :: InStr'1 -> Str'Dynamic -- | Determines whether an InStr'1 contains any non-space -- characters. The opposite of inStr'1'nonEmpty. -- -- This is used to determine whether this line should be considered when -- calculating the number of space characters to strip in -- inStr'dedent. inStr'1'nonEmpty :: InStr'1 -> Bool -- | The opposite of inStr'1'nonEmpty. inStr'1'empty :: InStr'1 -> Bool -- | Modify an InStr by applying a function to its number of leading -- spaces. inStr'1'modifyLevel :: (Natural -> Natural) -> (InStr'1 -> InStr'1) -- | A list literal expression, starting with [ and ending with -- ]. See Expr'List. newtype List List :: (Seq Expression) -> List -- | Render a list literal ([ ... ]). render'list :: Render List -- | Parser for a list expression ([ ... ]). -- --
--   >>> parseTest parse'list "[]"
--   list []
--   
-- --
--   >>> parseTest parse'list "[x \"one\" (a: b) (c d)]"
--   list [var "x", str ["one"], lambda (param "a") (var "b"), apply (var "c") (var "d")]
--   
parse'list :: Parser List -- | A dict literal expression, starting with { or rec { -- and ending with }. See Expr'Dict. data Dict Dict :: Bool -> Seq DictBinding -> Dict -- | Whether the dict is recursive (denoted by the rec keyword) [dict'rec] :: Dict -> Bool -- | The bindings (everything between { and }) [dict'bindings] :: Dict -> Seq DictBinding keyword'rec :: Keyword -- | Render a dict literal ({ ... }). render'dict :: Render Dict -- | Parser for a dict expression, either recursive (rec keyword) -- or not. -- --
--   >>> parseTest parse'dict "{}"
--   dict []
--   
-- --
--   >>> parseTest parse'dict "rec {  }"
--   rec'dict []
--   
-- --
--   >>> parseTest parse'dict "{ a = b; inherit (x) y z \"s t\"; }"
--   dict [binding (str ["a"]) (var "b"), inherit'from (var "x") ["y", "z", "s t"]]
--   
parse'dict :: Parser Dict -- | Parser for a recursive (rec keyword) dict. -- --
--   >>> parseTest parse'dict "rec {  }"
--   rec'dict []
--   
-- --
--   >>> parseTest parse'dict "rec { a = \"1\"; b = \"${a}2\"; }"
--   rec'dict [binding (str ["a"]) (str ["1"]), binding (str ["b"]) (str [antiquote (var "a"), "2"])]
--   
parse'dict'rec :: Parser (Seq DictBinding) -- | Parser for a non-recursive (no rec keyword) dict. -- --
--   >>> parseTest parse'dict "{  }"
--   dict []
--   
-- --
--   >>> parseTest parse'dict "{ a = \"1\"; b = \"${a}2\"; }"
--   dict [binding (str ["a"]) (str ["1"]), binding (str ["b"]) (str [antiquote (var "a"), "2"])]
--   
parse'dict'noRec :: Parser (Seq DictBinding) -- | A binding of the form x = y; within a DictLiteral or -- LetExpr. data DictBinding DictBinding'Eq :: Expression -> Expression -> DictBinding DictBinding'Inherit :: Inherit -> DictBinding -- | Render a binding within a Dict, without the trailing semicolon. render'dictBinding :: Render DictBinding parse'dictBinding :: Parser DictBinding parse'dictBinding'inherit :: Parser DictBinding parse'dictBinding'eq :: Parser DictBinding -- | An expression of the form person.name that looks up a key -- from a dict. See Expr'Dot. data Dot Dot :: Expression -> Expression -> Dot [dot'dict] :: Dot -> Expression [dot'key] :: Dot -> Expression expression'applyDots :: Expression -> [Expression] -> Expression -- | Render a dot expression (a.b). render'dot :: Render Dot -- | Parser for a chain of dict lookups (like .a.b.c) on the -- right-hand side of a Dot expression. -- --
--   >>> parseTest parse'dot'rhs'chain ""
--   []
--   
-- --
--   >>> parseTest parse'dot'rhs'chain ".abc"
--   [str ["abc"]]
--   
-- --
--   >>> parseTest parse'dot'rhs'chain ".a.${b}.\"c\".\"d${e}\""
--   [str ["a"],var "b",str ["c"],str ["d", antiquote (var "e")]]
--   
parse'dot'rhs'chain :: Parser [Expression] -- | A function expression. See Expr'Lambda. data Lambda Lambda :: Param -> Expression -> Lambda -- | Declaration of the function's parameter [lambda'head] :: Lambda -> Param -- | Body of the function; what it evaluates to [lambda'body] :: Lambda -> Expression -- | Render a lambda expression (x: y). render'lambda :: Render Lambda -- | Parser for a lambda expression (x: y). -- --
--   >>> parseTest parse'lambda "x: [x x \"a\"]"
--   lambda (param "x") (list [var "x", var "x", str ["a"]])
--   
-- --
--   >>> parseTest parse'lambda "{a,b}:a"
--   lambda (pattern [param "a", param "b"]) (var "a")
--   
-- --
--   >>> parseTest parse'lambda "{ ... }: \"x\""
--   lambda (pattern [] <> ellipsis) (str ["x"])
--   
-- --
--   >>> parseTest parse'lambda "a@{ f, b ? g x, ... }: f b"
--   lambda (param "a" <> pattern [param "f", param "b" & def (apply (var "g") (var "x"))] <> ellipsis) (apply (var "f") (var "b"))
--   
-- --
--   >>> parseTest parse'lambda "a: b: \"x\""
--   lambda (param "a") (lambda (param "b") (str ["x"]))
--   
parse'lambda :: Parser Lambda -- | A parameter to a Lambda. All functions have a single parameter, -- but it's more complicated than that because it may also include dict -- destructuring. data Param -- | A simple single-parameter function Param'Name :: Str'Unquoted -> Param -- | Dict destructuring, which gives you something resembling multiple -- named parameters with default values Param'DictPattern :: DictPattern -> Param -- | Both a param name and a dict pattern, separated by the -- @ keyword Param'Both :: Str'Unquoted -> DictPattern -> Param -- | Render a lambda parameter: everything from the beginning of a lambda, -- up to but not including the : that separates the head from -- the body of the lambda. render'param :: Render Param -- | Parser for a function parameter (the beginning of a Lambda), -- including the colon. This forms part of parse'expression, so it -- backtracks in places where it has overlap with other types of -- expressions. parse'param :: Parser Param -- | Parser for a parameter that starts with a variable. This could be a -- simple param that consists only of only the variable, or the -- variable may be followed by a dict pattern. parse'param'var :: Parser Param -- | Parser for a param that has no variable, only a a dict pattern. This -- parser backtracks because the beginning of a dict pattern looks like -- the beginning of a dict expression. parse'param'noVar :: Parser Param -- | A type of function parameter (Param) that does dict -- destructuring. data DictPattern DictPattern :: Seq DictPattern'1 -> Bool -> DictPattern -- | The list of keys to pull out of the dict, along with any default value -- each may have [dictPattern'items] :: DictPattern -> Seq DictPattern'1 -- | Whether to allow additional keys beyond what is listed in the items, -- corresponding to the ... keyword [dictPattern'ellipsis] :: DictPattern -> Bool -- | One item within a DictPattern. data DictPattern'1 DictPattern'1 :: Str'Unquoted -> Maybe Expression -> DictPattern'1 -- | The name of the key to pull out of the dict [dictPattern'1'name] :: DictPattern'1 -> Str'Unquoted -- | The default value to be used if the key is not present in the dict [dictPattern'1'default] :: DictPattern'1 -> Maybe Expression -- | Render a dict pattern ({ a, b ? c, ... }). render'dictPattern :: Render DictPattern -- | Render a single item in a DictPattern. render'dictPattern'1 :: Render DictPattern'1 -- | Parser for a dict pattern (the type of lambda parameter that does dict -- destructuring. This parser does not backtrack. parse'dictPattern :: Parser DictPattern -- | This is used in a lookahead by parse'param to determine whether -- we're about to start parsing a DictPattern. parse'dictPattern'start :: Parser () -- | A function application expression. See Expr'Apply. data Apply Apply :: Expression -> Expression -> Apply -- | The function being called [apply'func] :: Apply -> Expression -- | The argument to the function [apply'arg] :: Apply -> Expression expression'applyArgs :: Expression -> [Expression] -> Expression -- | Render a function application expression (f x). render'apply :: Render Apply -- | A let-in expression. See Expr'Let. data Let Let :: Seq LetBinding -> Expression -> Let -- | The bindings (everything between the let and in -- keywords) [let'bindings] :: Let -> Seq LetBinding -- | The value (everything after the in keyword) [let'value] :: Let -> Expression keyword'let :: Keyword keyword'in :: Keyword -- | Render a let-in expression. render'let :: Render Let parse'let :: Parser Let -- | A semicolon-terminated binding within the binding list of a Let -- expression. data LetBinding -- | A binding with an equals sign, of the form x = y; LetBinding'Eq :: Str'Static -> Expression -> LetBinding -- | A binding using the inherit keyword, of the form inherit -- a b; or inherit (x) a b; LetBinding'Inherit :: Inherit -> LetBinding -- | Render a binding within a Let, without the trailing semicolon. render'letBinding :: Render LetBinding parse'letBinding :: Parser LetBinding parse'letBinding'eq :: Parser LetBinding parse'letBinding'inherit :: Parser LetBinding -- | A with expression. See Expr'With. data With With :: Expression -> Expression -> With [with'context] :: With -> Expression [with'value] :: With -> Expression keyword'with :: Keyword -- | Render a with expression. render'with :: Render With parse'with :: Parser With data Inherit Inherit :: Maybe Expression -> Seq Str'Static -> Inherit [inherit'source] :: Inherit -> Maybe Expression [inherit'names] :: Inherit -> Seq Str'Static keyword'inherit :: Keyword render'inherit :: Render Inherit parse'inherit :: Parser Inherit data Keyword -- | All of the keywords. This list is used when parsing and rendering -- because an unquoted string cannot have a name that is exactly the same -- as a keyword. keywords :: [Keyword] keywordString :: Keyword -> String keywordText :: Keyword -> Text -- | Backtracking parser for a particular keyword. parse'keyword :: Keyword -> Parser () keyword'inlineComment :: Keyword parse'spaces :: Parser () parse'comment :: Parser () parse'comment'inline :: Parser () parse'comment'block :: Parser () type Render a = a -> Text parse'antiquote :: Parser Str'Dynamic