-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A configuration language guaranteed to terminate
--   
--   Dhall is an explicitly typed configuration language that is not Turing
--   complete. Despite being Turing incomplete, Dhall is a real programming
--   language with a type-checker and evaluator.
--   
--   Use this library to parse, type-check, evaluate, and pretty-print the
--   Dhall configuration language. This package also includes an executable
--   which type-checks a Dhall file and reduces the file to a fully
--   evaluated normal form.
--   
--   Read <a>Dhall.Tutorial</a> to learn how to use this library
@package dhall
@version 1.15.1


-- | This is a utility module that consolidates all <a>Context</a>-related
--   operations
module Dhall.Context

-- | A <tt>(Context a)</tt> associates <a>Text</a> labels with values of
--   type <tt>a</tt>. Each <a>Text</a> label can correspond to multiple
--   values of type <tt>a</tt>
--   
--   The <a>Context</a> is used for type-checking when <tt>(a = Expr
--   X)</tt>
--   
--   <ul>
--   <li>You create a <a>Context</a> using <a>empty</a> and
--   <a>insert</a></li>
--   <li>You transform a <a>Context</a> using <a>fmap</a></li>
--   <li>You consume a <a>Context</a> using <a>lookup</a> and
--   <a>toList</a></li>
--   </ul>
--   
--   The difference between a <a>Context</a> and a <a>Map</a> is that a
--   <a>Context</a> lets you have multiple ordered occurrences of the same
--   key and you can query for the <tt>n</tt>th occurrence of a given key.
data Context a

-- | An empty context with no key-value pairs
empty :: Context a

-- | Add a key-value pair to the <a>Context</a>
insert :: Text -> a -> Context a -> Context a

-- | "Pattern match" on a <a>Context</a>
--   
--   <pre>
--   match (insert k v ctx) = Just (k, v, ctx)
--   match  empty           = Nothing
--   </pre>
match :: Context a -> Maybe (Text, a, Context a)

-- | Look up a key by name and index
--   
--   <pre>
--   lookup _ _         empty  = Nothing
--   lookup k 0 (insert k v c) = Just v
--   lookup k n (insert k v c) = lookup k (n - 1) c
--   lookup k n (insert j v c) = lookup k  n      c  -- k /= j
--   </pre>
lookup :: Text -> Integer -> Context a -> Maybe a

-- | Return all key-value associations as a list
--   
--   <pre>
--   toList           empty  = []
--   toList (insert k v ctx) = (k, v) : toList ctx
--   </pre>
toList :: Context a -> [(Text, a)]
instance GHC.Base.Functor Dhall.Context.Context


-- | This module contains the core calculus for the Dhall language.
--   
--   Dhall is essentially a fork of the <tt>morte</tt> compiler but with
--   more built-in functionality, better error messages, and Haskell
--   integration
module Dhall.Core

-- | Constants for a pure type system
--   
--   The only axiom is:
--   
--   <pre>
--   ⊦ Type : Kind
--   </pre>
--   
--   ... and the valid rule pairs are:
--   
--   <pre>
--   ⊦ Type ↝ Type : Type  -- Functions from terms to terms (ordinary functions)
--   ⊦ Kind ↝ Type : Type  -- Functions from types to terms (polymorphic functions)
--   ⊦ Kind ↝ Kind : Kind  -- Functions from types to types (type constructors)
--   </pre>
--   
--   These are the same rule pairs as System Fω
--   
--   Note that Dhall does not support functions from terms to types and
--   therefore Dhall is not a dependently typed language
data Const
Type :: Const
Kind :: Const

-- | Internal representation of a directory that stores the path components
--   in reverse order
--   
--   In other words, the directory <tt>/foo/bar/baz</tt> is encoded as
--   <tt>Directory { components = [ "baz", "bar", "foo" ] }</tt>
newtype Directory
Directory :: [Text] -> Directory
[components] :: Directory -> [Text]

-- | A <a>File</a> is a <a>directory</a> followed by one additional path
--   component representing the <a>file</a> name
data File
File :: Directory -> Text -> File
[directory] :: File -> Directory
[file] :: File -> Text
data FilePrefix

-- | Absolute path
Absolute :: FilePrefix

-- | Path relative to <tt>.</tt>
Here :: FilePrefix

-- | Path relative to <tt>~</tt>
Home :: FilePrefix

-- | Reference to an external resource
data Import
Import :: ImportHashed -> ImportMode -> Import
[importHashed] :: Import -> ImportHashed
[importMode] :: Import -> ImportMode

-- | A <a>ImportType</a> extended with an optional hash for semantic
--   integrity checks
data ImportHashed
ImportHashed :: Maybe (Digest SHA256) -> ImportType -> ImportHashed
[hash] :: ImportHashed -> Maybe (Digest SHA256)
[importType] :: ImportHashed -> ImportType

-- | How to interpret the import's contents (i.e. as Dhall code or raw
--   text)
data ImportMode
Code :: ImportMode
RawText :: ImportMode

-- | The type of import (i.e. local vs. remote vs. environment)
data ImportType

-- | Local path
Local :: FilePrefix -> File -> ImportType

-- | URL of remote resource and optional headers stored in an import
URL :: Text -> File -> Text -> (Maybe ImportHashed) -> ImportType

-- | Environment variable
Env :: Text -> ImportType
Missing :: ImportType

-- | Type synonym for <a>Import</a>, provided for backwards compatibility

-- | <i>Deprecated: Use Dhall.Core.Import instead</i>
type Path = Import

-- | Label for a bound variable
--   
--   The <a>Text</a> field is the variable's name (i.e. "<tt>x</tt>").
--   
--   The <a>Int</a> field disambiguates variables with the same name if
--   there are multiple bound variables of the same name in scope. Zero
--   refers to the nearest bound variable and the index increases by one
--   for each bound variable of the same name going outward. The following
--   diagram may help:
--   
--   <pre>
--                                 ┌──refers to──┐
--                                 │             │
--                                 v             │
--   λ(x : Type) → λ(y : Type) → λ(x : Type) → x@0
--   
--   ┌─────────────────refers to─────────────────┐
--   │                                           │
--   v                                           │
--   λ(x : Type) → λ(y : Type) → λ(x : Type) → x@1
--   </pre>
--   
--   This <a>Int</a> behaves like a De Bruijn index in the special case
--   where all variables have the same name.
--   
--   You can optionally omit the index if it is <tt>0</tt>:
--   
--   <pre>
--                                 ┌─refers to─┐
--                                 │           │
--                                 v           │
--   λ(x : Type) → λ(y : Type) → λ(x : Type) → x
--   </pre>
--   
--   Zero indices are omitted when pretty-printing <a>Var</a>s and non-zero
--   indices appear as a numeric suffix.
data Var
V :: Text -> !Integer -> Var

-- | The body of an interpolated <tt>Text</tt> literal
data Chunks s a
Chunks :: [(Text, Expr s a)] -> Text -> Chunks s a

-- | Syntax tree for expressions
data Expr s a

-- | <pre>
--   Const c                                  ~  c
--   </pre>
Const :: Const -> Expr s a

-- | <pre>
--   Var (V x 0)                              ~  x
--   Var (V x n)                              ~  x@n
--   </pre>
Var :: Var -> Expr s a

-- | <pre>
--   Lam x     A b                            ~  λ(x : A) -&gt; b
--   </pre>
Lam :: Text -> (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   Pi "_" A B                               ~        A  -&gt; B
--   Pi x   A B                               ~  ∀(x : A) -&gt; B
--   </pre>
Pi :: Text -> (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   App f a                                  ~  f a
--   </pre>
App :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   Let x Nothing  r e                       ~  let x     = r in e
--   Let x (Just t) r e                       ~  let x : t = r in e
--   </pre>
Let :: Text -> (Maybe (Expr s a)) -> (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   Annot x t                                ~  x : t
--   </pre>
Annot :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   Bool                                     ~  Bool
--   </pre>
Bool :: Expr s a

-- | <pre>
--   BoolLit b                                ~  b
--   </pre>
BoolLit :: Bool -> Expr s a

-- | <pre>
--   BoolAnd x y                              ~  x &amp;&amp; y
--   </pre>
BoolAnd :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   BoolOr  x y                              ~  x || y
--   </pre>
BoolOr :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   BoolEQ  x y                              ~  x == y
--   </pre>
BoolEQ :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   BoolNE  x y                              ~  x != y
--   </pre>
BoolNE :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   BoolIf x y z                             ~  if x then y else z
--   </pre>
BoolIf :: (Expr s a) -> (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   Natural                                  ~  Natural
--   </pre>
Natural :: Expr s a

-- | <pre>
--   NaturalLit n                             ~  n
--   </pre>
NaturalLit :: Natural -> Expr s a

-- | <pre>
--   NaturalFold                              ~  Natural/fold
--   </pre>
NaturalFold :: Expr s a

-- | <pre>
--   NaturalBuild                             ~  Natural/build
--   </pre>
NaturalBuild :: Expr s a

-- | <pre>
--   NaturalIsZero                            ~  Natural/isZero
--   </pre>
NaturalIsZero :: Expr s a

-- | <pre>
--   NaturalEven                              ~  Natural/even
--   </pre>
NaturalEven :: Expr s a

-- | <pre>
--   NaturalOdd                               ~  Natural/odd
--   </pre>
NaturalOdd :: Expr s a

-- | <pre>
--   NaturalToInteger                         ~  Natural/toInteger
--   </pre>
NaturalToInteger :: Expr s a

-- | <pre>
--   NaturalShow                              ~  Natural/show
--   </pre>
NaturalShow :: Expr s a

-- | <pre>
--   NaturalPlus x y                          ~  x + y
--   </pre>
NaturalPlus :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   NaturalTimes x y                         ~  x * y
--   </pre>
NaturalTimes :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   Integer                                  ~  Integer
--   </pre>
Integer :: Expr s a

-- | <pre>
--   IntegerLit n                             ~  ±n
--   </pre>
IntegerLit :: Integer -> Expr s a

-- | <pre>
--   IntegerShow                              ~  Integer/show
--   </pre>
IntegerShow :: Expr s a

-- | <pre>
--   IntegerToDouble                          ~  Integer/toDouble
--   </pre>
IntegerToDouble :: Expr s a

-- | <pre>
--   Double                                   ~  Double
--   </pre>
Double :: Expr s a

-- | <pre>
--   DoubleLit n                              ~  n
--   </pre>
DoubleLit :: Scientific -> Expr s a

-- | <pre>
--   DoubleShow                               ~  Double/show
--   </pre>
DoubleShow :: Expr s a

-- | <pre>
--   Text                                     ~  Text
--   </pre>
Text :: Expr s a

-- | <pre>
--   TextLit (Chunks [(t1, e1), (t2, e2)] t3) ~  "t1${e1}t2${e2}t3"
--   </pre>
TextLit :: (Chunks s a) -> Expr s a

-- | <pre>
--   TextAppend x y                           ~  x ++ y
--   </pre>
TextAppend :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   List                                     ~  List
--   </pre>
List :: Expr s a

-- | <pre>
--   ListLit (Just t ) [x, y, z]              ~  [x, y, z] : List t
--   ListLit  Nothing  [x, y, z]              ~  [x, y, z]
--   </pre>
ListLit :: (Maybe (Expr s a)) -> (Seq (Expr s a)) -> Expr s a

-- | <pre>
--   ListAppend x y                           ~  x # y
--   </pre>
ListAppend :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   ListBuild                                ~  List/build
--   </pre>
ListBuild :: Expr s a

-- | <pre>
--   ListFold                                 ~  List/fold
--   </pre>
ListFold :: Expr s a

-- | <pre>
--   ListLength                               ~  List/length
--   </pre>
ListLength :: Expr s a

-- | <pre>
--   ListHead                                 ~  List/head
--   </pre>
ListHead :: Expr s a

-- | <pre>
--   ListLast                                 ~  List/last
--   </pre>
ListLast :: Expr s a

-- | <pre>
--   ListIndexed                              ~  List/indexed
--   </pre>
ListIndexed :: Expr s a

-- | <pre>
--   ListReverse                              ~  List/reverse
--   </pre>
ListReverse :: Expr s a

-- | <pre>
--   Optional                                 ~  Optional
--   </pre>
Optional :: Expr s a

-- | <pre>
--   OptionalLit t (Just e)                   ~  [e] : Optional t
--   OptionalLit t Nothing                    ~  []  : Optional t
--   </pre>
OptionalLit :: (Expr s a) -> (Maybe (Expr s a)) -> Expr s a

-- | <pre>
--   OptionalFold                             ~  Optional/fold
--   </pre>
OptionalFold :: Expr s a

-- | <pre>
--   OptionalBuild                            ~  Optional/build
--   </pre>
OptionalBuild :: Expr s a

-- | <pre>
--   Record       [(k1, t1), (k2, t2)]        ~  { k1 : t1, k2 : t1 }
--   </pre>
Record :: (InsOrdHashMap Text (Expr s a)) -> Expr s a

-- | <pre>
--   RecordLit    [(k1, v1), (k2, v2)]        ~  { k1 = v1, k2 = v2 }
--   </pre>
RecordLit :: (InsOrdHashMap Text (Expr s a)) -> Expr s a

-- | <pre>
--   Union        [(k1, t1), (k2, t2)]        ~  &lt; k1 : t1 | k2 : t2 &gt;
--   </pre>
Union :: (InsOrdHashMap Text (Expr s a)) -> Expr s a

-- | <pre>
--   UnionLit k v [(k1, t1), (k2, t2)]        ~  &lt; k = v | k1 : t1 | k2 : t2 &gt;
--   </pre>
UnionLit :: Text -> (Expr s a) -> (InsOrdHashMap Text (Expr s a)) -> Expr s a

-- | <pre>
--   Combine x y                              ~  x ∧ y
--   </pre>
Combine :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   CombineTypes x y                         ~  x ⩓ y
--   </pre>
CombineTypes :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   CombineRight x y                         ~  x ⫽ y
--   </pre>
Prefer :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   Merge x y (Just t )                      ~  merge x y : t
--   Merge x y  Nothing                       ~  merge x y
--   </pre>
Merge :: (Expr s a) -> (Expr s a) -> (Maybe (Expr s a)) -> Expr s a

-- | <pre>
--   Constructors e                           ~  constructors e
--   </pre>
Constructors :: (Expr s a) -> Expr s a

-- | <pre>
--   Field e x                                ~  e.x
--   </pre>
Field :: (Expr s a) -> Text -> Expr s a

-- | <pre>
--   Project e xs                             ~  e.{ xs }
--   </pre>
Project :: (Expr s a) -> (Set Text) -> Expr s a

-- | <pre>
--   Note s x                                 ~  e
--   </pre>
Note :: s -> (Expr s a) -> Expr s a

-- | <pre>
--   ImportAlt                                ~  e1 ? e2
--   </pre>
ImportAlt :: (Expr s a) -> (Expr s a) -> Expr s a

-- | <pre>
--   Embed import                             ~  import
--   </pre>
Embed :: a -> Expr s a

-- | α-normalize an expression by renaming all variables to <tt>"_"</tt>
--   and using De Bruijn indices to distinguish them
alphaNormalize :: Expr s a -> Expr s a

-- | Reduce an expression to its normal form, performing beta reduction
--   
--   <a>normalize</a> does not type-check the expression. You may want to
--   type-check expressions before normalizing them since normalization can
--   convert an ill-typed expression into a well-typed expression.
--   
--   However, <a>normalize</a> will not fail if the expression is ill-typed
--   and will leave ill-typed sub-expressions unevaluated.
normalize :: Eq a => Expr s a -> Expr t a

-- | Reduce an expression to its normal form, performing beta reduction and
--   applying any custom definitions.
--   
--   <a>normalizeWith</a> is designed to be used with function
--   <tt>typeWith</tt>. The <tt>typeWith</tt> function allows typing of
--   Dhall functions in a custom typing context whereas
--   <a>normalizeWith</a> allows evaluating Dhall expressions in a custom
--   context.
--   
--   To be more precise <a>normalizeWith</a> applies the given normalizer
--   when it finds an application term that it cannot reduce by other
--   means.
--   
--   Note that the context used in normalization will determine the
--   properties of normalization. That is, if the functions in custom
--   context are not total then the Dhall language, evaluated with those
--   functions is not total either.
normalizeWith :: Eq a => Normalizer a -> Expr s a -> Expr t a

-- | Use this to wrap you embedded functions (see <a>normalizeWith</a>) to
--   make them polymorphic enough to be used.
type Normalizer a = forall s. Expr s a -> Maybe (Expr s a)

-- | Returns <a>True</a> if two expressions are α-equivalent and
--   β-equivalent and <a>False</a> otherwise
judgmentallyEqual :: Eq a => Expr s a -> Expr t a -> Bool

-- | Substitute all occurrences of a variable with an expression
--   
--   <pre>
--   subst x C B  ~  B[x := C]
--   </pre>
subst :: Var -> Expr s a -> Expr s a -> Expr s a

-- | <a>shift</a> is used by both normalization and type-checking to avoid
--   variable capture by shifting variable indices
--   
--   For example, suppose that you were to normalize the following
--   expression:
--   
--   <pre>
--   λ(a : Type) → λ(x : a) → (λ(y : a) → λ(x : a) → y) x
--   </pre>
--   
--   If you were to substitute <tt>y</tt> with <tt>x</tt> without shifting
--   any variable indices, then you would get the following incorrect
--   result:
--   
--   <pre>
--   λ(a : Type) → λ(x : a) → λ(x : a) → x  -- Incorrect normalized form
--   </pre>
--   
--   In order to substitute <tt>x</tt> in place of <tt>y</tt> we need to
--   <a>shift</a> <tt>x</tt> by <tt>1</tt> in order to avoid being
--   misinterpreted as the <tt>x</tt> bound by the innermost lambda. If we
--   perform that <a>shift</a> then we get the correct result:
--   
--   <pre>
--   λ(a : Type) → λ(x : a) → λ(x : a) → x@1
--   </pre>
--   
--   As a more worked example, suppose that you were to normalize the
--   following expression:
--   
--   <pre>
--       λ(a : Type)
--   →   λ(f : a → a → a)
--   →   λ(x : a)
--   →   λ(x : a)
--   →   (λ(x : a) → f x x@1) x@1
--   </pre>
--   
--   The correct normalized result would be:
--   
--   <pre>
--       λ(a : Type)
--   →   λ(f : a → a → a)
--   →   λ(x : a)
--   →   λ(x : a)
--   →   f x@1 x
--   </pre>
--   
--   The above example illustrates how we need to both increase and
--   decrease variable indices as part of substitution:
--   
--   <ul>
--   <li>We need to increase the index of the outer <tt>x@1</tt> to
--   <tt>x@2</tt> before we substitute it into the body of the innermost
--   lambda expression in order to avoid variable capture. This
--   substitution changes the body of the lambda expression to <tt>(f x@2
--   x@1)</tt></li>
--   <li>We then remove the innermost lambda and therefore decrease the
--   indices of both <tt>x</tt>s in <tt>(f x@2 x@1)</tt> to <tt>(f x@1
--   x)</tt> in order to reflect that one less <tt>x</tt> variable is now
--   bound within that scope</li>
--   </ul>
--   
--   Formally, <tt>(shift d (V x n) e)</tt> modifies the expression
--   <tt>e</tt> by adding <tt>d</tt> to the indices of all variables named
--   <tt>x</tt> whose indices are greater than <tt>(n + m)</tt>, where
--   <tt>m</tt> is the number of bound variables of the same name within
--   that scope
--   
--   In practice, <tt>d</tt> is always <tt>1</tt> or <tt>-1</tt> because we
--   either:
--   
--   <ul>
--   <li>increment variables by <tt>1</tt> to avoid variable capture during
--   substitution</li>
--   <li>decrement variables by <tt>1</tt> when deleting lambdas after
--   substitution</li>
--   </ul>
--   
--   <tt>n</tt> starts off at <tt>0</tt> when substitution begins and
--   increments every time we descend into a lambda or let expression that
--   binds a variable of the same name in order to avoid shifting the bound
--   variables by mistake.
shift :: Integer -> Var -> Expr s a -> Expr s a

-- | Quickly check if an expression is in normal form
isNormalized :: Expr s a -> Bool

-- | Check if an expression is in a normal form given a context of
--   evaluation. Unlike <a>isNormalized</a>, this will fully normalize and
--   traverse through the expression.
--   
--   It is much more efficient to use <a>isNormalized</a>.
isNormalizedWith :: (Eq s, Eq a) => Normalizer a -> Expr s a -> Bool

-- | Remove all <a>Note</a> constructors from an <a>Expr</a> (i.e.
--   de-<a>Note</a>)
denote :: Expr s a -> Expr t a

-- | Detect if the given variable is free within the given expression
--   
--   <pre>
--   &gt;&gt;&gt; "x" `freeIn` "x"
--   True
--   
--   &gt;&gt;&gt; "x" `freeIn` "y"
--   False
--   
--   &gt;&gt;&gt; "x" `freeIn` Lam "x" (Const Type) "x"
--   False
--   </pre>
freeIn :: Eq a => Var -> Expr s a -> Bool
pretty :: Pretty a => a -> Text

-- | Utility function used to throw internal errors that should never
--   happen (in theory) but that are not enforced by the type system
internalError :: Text -> forall b. b

-- | The set of reserved identifiers for the Dhall language
reservedIdentifiers :: HashSet Text
escapeText :: Text -> Text
instance (Data.Data.Data s, Data.Data.Data a) => Data.Data.Data (Dhall.Core.Expr s a)
instance (GHC.Classes.Eq s, GHC.Classes.Eq a) => GHC.Classes.Eq (Dhall.Core.Expr s a)
instance (GHC.Show.Show s, GHC.Show.Show a) => GHC.Show.Show (Dhall.Core.Expr s a)
instance Data.Traversable.Traversable (Dhall.Core.Expr s)
instance Data.Foldable.Foldable (Dhall.Core.Expr s)
instance GHC.Base.Functor (Dhall.Core.Expr s)
instance (Data.Data.Data s, Data.Data.Data a) => Data.Data.Data (Dhall.Core.Chunks s a)
instance (GHC.Classes.Eq s, GHC.Classes.Eq a) => GHC.Classes.Eq (Dhall.Core.Chunks s a)
instance (GHC.Show.Show s, GHC.Show.Show a) => GHC.Show.Show (Dhall.Core.Chunks s a)
instance Data.Traversable.Traversable (Dhall.Core.Chunks s)
instance Data.Foldable.Foldable (Dhall.Core.Chunks s)
instance GHC.Base.Functor (Dhall.Core.Chunks s)
instance GHC.Show.Show Dhall.Core.Var
instance GHC.Classes.Eq Dhall.Core.Var
instance Data.Data.Data Dhall.Core.Var
instance GHC.Show.Show Dhall.Core.Import
instance GHC.Classes.Ord Dhall.Core.Import
instance GHC.Classes.Eq Dhall.Core.Import
instance GHC.Show.Show Dhall.Core.ImportType
instance GHC.Classes.Ord Dhall.Core.ImportType
instance GHC.Classes.Eq Dhall.Core.ImportType
instance GHC.Show.Show Dhall.Core.ImportHashed
instance GHC.Classes.Ord Dhall.Core.ImportHashed
instance GHC.Classes.Eq Dhall.Core.ImportHashed
instance GHC.Show.Show Dhall.Core.ImportMode
instance GHC.Classes.Ord Dhall.Core.ImportMode
instance GHC.Classes.Eq Dhall.Core.ImportMode
instance GHC.Show.Show Dhall.Core.FilePrefix
instance GHC.Classes.Ord Dhall.Core.FilePrefix
instance GHC.Classes.Eq Dhall.Core.FilePrefix
instance GHC.Show.Show Dhall.Core.File
instance GHC.Classes.Ord Dhall.Core.File
instance GHC.Classes.Eq Dhall.Core.File
instance GHC.Show.Show Dhall.Core.Directory
instance GHC.Classes.Ord Dhall.Core.Directory
instance GHC.Classes.Eq Dhall.Core.Directory
instance GHC.Enum.Enum Dhall.Core.Const
instance GHC.Enum.Bounded Dhall.Core.Const
instance Data.Data.Data Dhall.Core.Const
instance GHC.Classes.Eq Dhall.Core.Const
instance GHC.Show.Show Dhall.Core.Const
instance GHC.Base.Applicative (Dhall.Core.Expr s)
instance GHC.Base.Monad (Dhall.Core.Expr s)
instance Data.Bifunctor.Bifunctor Dhall.Core.Expr
instance Data.String.IsString (Dhall.Core.Expr s a)
instance GHC.Base.Semigroup (Dhall.Core.Chunks s a)
instance GHC.Base.Monoid (Dhall.Core.Chunks s a)
instance Data.String.IsString (Dhall.Core.Chunks s a)
instance Data.Text.Prettyprint.Doc.Internal.Pretty a => Data.Text.Prettyprint.Doc.Internal.Pretty (Dhall.Core.Expr s a)
instance Data.String.IsString Dhall.Core.Var
instance Data.Text.Prettyprint.Doc.Internal.Pretty Dhall.Core.Var
instance GHC.Base.Semigroup Dhall.Core.Import
instance Data.Text.Prettyprint.Doc.Internal.Pretty Dhall.Core.Import
instance GHC.Base.Semigroup Dhall.Core.ImportType
instance Data.Text.Prettyprint.Doc.Internal.Pretty Dhall.Core.ImportType
instance GHC.Base.Semigroup Dhall.Core.ImportHashed
instance Data.Text.Prettyprint.Doc.Internal.Pretty Dhall.Core.ImportHashed
instance Data.Text.Prettyprint.Doc.Internal.Pretty Dhall.Core.FilePrefix
instance Data.Text.Prettyprint.Doc.Internal.Pretty Dhall.Core.File
instance GHC.Base.Semigroup Dhall.Core.File
instance GHC.Base.Semigroup Dhall.Core.Directory
instance Data.Text.Prettyprint.Doc.Internal.Pretty Dhall.Core.Directory
instance Data.Text.Prettyprint.Doc.Internal.Pretty Dhall.Core.Const


-- | This module contains Dhall's parsing logic
module Dhall.Parser

-- | Parse an expression from <a>Text</a> containing a Dhall program
exprFromText :: String -> Text -> Either ParseError (Expr Src Import)

-- | Like <a>exprFromText</a> but also returns the leading comments and
--   whitespace (i.e. header) up to the last newline before the code begins
--   
--   In other words, if you have a Dhall file of the form:
--   
--   <pre>
--   -- Comment 1
--    2
--   </pre>
--   
--   Then this will preserve <tt>Comment 1</tt>, but not <tt>Comment 2</tt>
--   
--   This is used by <tt>dhall-format</tt> to preserve leading comments and
--   whitespace
exprAndHeaderFromText :: String -> Text -> Either ParseError (Text, Expr Src Import)

-- | Parser for a top-level Dhall expression
expr :: Parser (Expr Src Import)

-- | Parser for a top-level Dhall expression. The expression is
--   parameterized over any parseable type, allowing the language to be
--   extended as needed.
exprA :: Parser a -> Parser (Expr Src a)

-- | Source code extract
data Src
Src :: SourcePos -> SourcePos -> Text -> Src

-- | A parsing error
data ParseError
ParseError :: ParseError Char Void -> Text -> ParseError
[unwrap] :: ParseError -> ParseError Char Void
[input] :: ParseError -> Text

-- | A <a>Parser</a> that is almost identical to
--   <tt><a>Text.Megaparsec</a>.<a>Parsec</a></tt> except treating
--   Haskell-style comments as whitespace
newtype Parser a
Parser :: Parsec Void Text a -> Parser a
[unParser] :: Parser a -> Parsec Void Text a
instance GHC.Show.Show Dhall.Parser.ParseError
instance GHC.Exception.Exception Dhall.Parser.ParseError


-- | This module contains logic for pretty-printing expressions, including
--   support for syntax highlighting
module Dhall.Pretty

-- | Annotation type used to tag elements in a pretty-printed document for
--   syntax highlighting purposes
data Ann

-- | Used for syntactic keywords
Keyword :: Ann

-- | Syntax punctuation such as commas, parenthesis, and braces
Syntax :: Ann

-- | Record labels
Label :: Ann

-- | Literals such as integers and strings
Literal :: Ann

-- | Builtin types and values
Builtin :: Ann

-- | Operators
Operator :: Ann

-- | Convert annotations to their corresponding color for syntax
--   highlighting purposes
annToAnsiStyle :: Ann -> AnsiStyle

-- | Pretty print an expression
prettyExpr :: Pretty a => Expr s a -> Doc Ann

module Dhall.Format
format :: Maybe FilePath -> IO ()


-- | This module provides functionality for concisely displaying the
--   difference between two expressions
--   
--   For example, this is used in type errors to explain why the actual
--   type does not match the expected type
module Dhall.Diff

-- | Render the difference between the normal form of two expressions
diffNormalized :: (Eq a, Pretty a) => Expr s a -> Expr s a -> Doc Ann

-- | Render the difference between two expressions
diff :: (Eq a, Pretty a) => Expr s a -> Expr s a -> Doc Ann
instance GHC.Base.Semigroup Dhall.Diff.Diff
instance GHC.Base.Monoid Dhall.Diff.Diff
instance Data.String.IsString Dhall.Diff.Diff


-- | This module contains the logic for type checking Dhall code
module Dhall.TypeCheck

-- | Type-check an expression and return the expression's type if
--   type-checking succeeds or an error if type-checking fails
--   
--   <a>typeWith</a> does not necessarily normalize the type since full
--   normalization is not necessary for just type-checking. If you actually
--   care about the returned type then you may want to <a>normalize</a> it
--   afterwards.
--   
--   The supplied <a>Context</a> records the types of the names in scope.
--   If these are ill-typed, the return value may be ill-typed.
typeWith :: Context (Expr s X) -> Expr s X -> Either (TypeError s X) (Expr s X)

-- | <a>typeOf</a> is the same as <a>typeWith</a> with an empty context,
--   meaning that the expression must be closed (i.e. no free variables),
--   otherwise type-checking will fail.
typeOf :: Expr s X -> Either (TypeError s X) (Expr s X)

-- | Generalization of <a>typeWith</a> that allows type-checking the
--   <a>Embed</a> constructor with custom logic
typeWithA :: Eq a => Typer a -> Context (Expr s a) -> Expr s a -> Either (TypeError s a) (Expr s a)

-- | This function verifies that a custom context is well-formed so that
--   type-checking will not loop
--   
--   Note that <a>typeWith</a> already calls <a>checkContext</a> for you on
--   the <a>Context</a> that you supply
checkContext :: Context (Expr s X) -> Either (TypeError s X) ()

-- | Function that converts the value inside an <a>Embed</a> constructor
--   into a new expression
type Typer a = forall s. a -> Expr s a

-- | Like <a>Void</a>, except with a shorter inferred type
newtype X
X :: forall a. a -> X
[absurd] :: X -> forall a. a

-- | A structured type error that includes context
data TypeError s a
TypeError :: Context (Expr s a) -> Expr s a -> TypeMessage s a -> TypeError s a
[context] :: TypeError s a -> Context (Expr s a)
[current] :: TypeError s a -> Expr s a
[typeMessage] :: TypeError s a -> TypeMessage s a

-- | Newtype used to wrap error messages so that they render with a more
--   detailed explanation of what went wrong
newtype DetailedTypeError s a
DetailedTypeError :: (TypeError s a) -> DetailedTypeError s a

-- | The specific type error
data TypeMessage s a
UnboundVariable :: Text -> TypeMessage s a
InvalidInputType :: (Expr s a) -> TypeMessage s a
InvalidOutputType :: (Expr s a) -> TypeMessage s a
NotAFunction :: (Expr s a) -> (Expr s a) -> TypeMessage s a
TypeMismatch :: (Expr s a) -> (Expr s a) -> (Expr s a) -> (Expr s a) -> TypeMessage s a
AnnotMismatch :: (Expr s a) -> (Expr s a) -> (Expr s a) -> TypeMessage s a
Untyped :: TypeMessage s a
MissingListType :: TypeMessage s a
MismatchedListElements :: Int -> (Expr s a) -> (Expr s a) -> (Expr s a) -> TypeMessage s a
InvalidListElement :: Int -> (Expr s a) -> (Expr s a) -> (Expr s a) -> TypeMessage s a
InvalidListType :: (Expr s a) -> TypeMessage s a
InvalidOptionalElement :: (Expr s a) -> (Expr s a) -> (Expr s a) -> TypeMessage s a
InvalidOptionalType :: (Expr s a) -> TypeMessage s a
InvalidPredicate :: (Expr s a) -> (Expr s a) -> TypeMessage s a
IfBranchMismatch :: (Expr s a) -> (Expr s a) -> (Expr s a) -> (Expr s a) -> TypeMessage s a
IfBranchMustBeTerm :: Bool -> (Expr s a) -> (Expr s a) -> (Expr s a) -> TypeMessage s a
InvalidField :: Text -> (Expr s a) -> TypeMessage s a
InvalidFieldType :: Text -> (Expr s a) -> TypeMessage s a
FieldAnnotationMismatch :: Text -> (Expr s a) -> Text -> (Expr s a) -> Const -> TypeMessage s a
FieldMismatch :: Text -> (Expr s a) -> Text -> (Expr s a) -> Const -> TypeMessage s a
InvalidAlternative :: Text -> (Expr s a) -> TypeMessage s a
InvalidAlternativeType :: Text -> (Expr s a) -> TypeMessage s a
ListAppendMismatch :: (Expr s a) -> (Expr s a) -> TypeMessage s a
DuplicateAlternative :: Text -> TypeMessage s a
MustCombineARecord :: Char -> (Expr s a) -> (Expr s a) -> TypeMessage s a
CombineTypesRequiresRecordType :: (Expr s a) -> (Expr s a) -> TypeMessage s a
RecordTypeMismatch :: Const -> Const -> (Expr s a) -> (Expr s a) -> TypeMessage s a
FieldCollision :: Text -> TypeMessage s a
MustMergeARecord :: (Expr s a) -> (Expr s a) -> TypeMessage s a
MustMergeUnion :: (Expr s a) -> (Expr s a) -> TypeMessage s a
UnusedHandler :: (Set Text) -> TypeMessage s a
MissingHandler :: (Set Text) -> TypeMessage s a
HandlerInputTypeMismatch :: Text -> (Expr s a) -> (Expr s a) -> TypeMessage s a
HandlerOutputTypeMismatch :: Text -> (Expr s a) -> Text -> (Expr s a) -> TypeMessage s a
InvalidHandlerOutputType :: Text -> (Expr s a) -> (Expr s a) -> TypeMessage s a
MissingMergeType :: TypeMessage s a
HandlerNotAFunction :: Text -> (Expr s a) -> TypeMessage s a
ConstructorsRequiresAUnionType :: (Expr s a) -> (Expr s a) -> TypeMessage s a
NotARecord :: Text -> (Expr s a) -> (Expr s a) -> TypeMessage s a
MissingField :: Text -> (Expr s a) -> TypeMessage s a
CantAnd :: (Expr s a) -> (Expr s a) -> TypeMessage s a
CantOr :: (Expr s a) -> (Expr s a) -> TypeMessage s a
CantEQ :: (Expr s a) -> (Expr s a) -> TypeMessage s a
CantNE :: (Expr s a) -> (Expr s a) -> TypeMessage s a
CantInterpolate :: (Expr s a) -> (Expr s a) -> TypeMessage s a
CantTextAppend :: (Expr s a) -> (Expr s a) -> TypeMessage s a
CantListAppend :: (Expr s a) -> (Expr s a) -> TypeMessage s a
CantAdd :: (Expr s a) -> (Expr s a) -> TypeMessage s a
CantMultiply :: (Expr s a) -> (Expr s a) -> TypeMessage s a
NoDependentTypes :: (Expr s a) -> (Expr s a) -> TypeMessage s a
instance (GHC.Show.Show s, GHC.Show.Show a) => GHC.Show.Show (Dhall.TypeCheck.TypeMessage s a)
instance (GHC.Classes.Eq a, Data.Text.Prettyprint.Doc.Internal.Pretty s, Data.Text.Prettyprint.Doc.Internal.Pretty a) => GHC.Show.Show (Dhall.TypeCheck.DetailedTypeError s a)
instance (GHC.Classes.Eq a, Data.Text.Prettyprint.Doc.Internal.Pretty s, Data.Text.Prettyprint.Doc.Internal.Pretty a, Data.Typeable.Internal.Typeable s, Data.Typeable.Internal.Typeable a) => GHC.Exception.Exception (Dhall.TypeCheck.DetailedTypeError s a)
instance (GHC.Classes.Eq a, Data.Text.Prettyprint.Doc.Internal.Pretty s, Data.Text.Prettyprint.Doc.Internal.Pretty a) => Data.Text.Prettyprint.Doc.Internal.Pretty (Dhall.TypeCheck.DetailedTypeError s a)
instance (GHC.Classes.Eq a, Data.Text.Prettyprint.Doc.Internal.Pretty s, Data.Text.Prettyprint.Doc.Internal.Pretty a) => GHC.Show.Show (Dhall.TypeCheck.TypeError s a)
instance (GHC.Classes.Eq a, Data.Text.Prettyprint.Doc.Internal.Pretty s, Data.Text.Prettyprint.Doc.Internal.Pretty a, Data.Typeable.Internal.Typeable s, Data.Typeable.Internal.Typeable a) => GHC.Exception.Exception (Dhall.TypeCheck.TypeError s a)
instance (GHC.Classes.Eq a, Data.Text.Prettyprint.Doc.Internal.Pretty s, Data.Text.Prettyprint.Doc.Internal.Pretty a) => Data.Text.Prettyprint.Doc.Internal.Pretty (Dhall.TypeCheck.TypeError s a)
instance GHC.Show.Show Dhall.TypeCheck.X
instance GHC.Classes.Eq Dhall.TypeCheck.X
instance Data.Data.Data Dhall.TypeCheck.X
instance Data.Text.Prettyprint.Doc.Internal.Pretty Dhall.TypeCheck.X

module Dhall.Lint
lint :: Expr s Import -> Expr t Import


-- | Dhall lets you import external expressions located either in local
--   files or hosted on network endpoints.
--   
--   To import a local file as an expression, just insert the path to the
--   file, prepending a <tt>./</tt> if the path is relative to the current
--   directory. For example, if you create a file named <tt>id</tt> with
--   the following contents:
--   
--   <pre>
--   $ cat id
--   λ(a : Type) → λ(x : a) → x
--   </pre>
--   
--   Then you can use the file directly within a <tt>dhall</tt> program
--   just by referencing the file's path:
--   
--   <pre>
--   $ dhall
--   ./id Bool True
--   &lt;Ctrl-D&gt;
--   Bool
--   
--   True
--   </pre>
--   
--   Imported expressions may contain imports of their own, too, which will
--   continue to be resolved. However, Dhall will prevent cyclic imports.
--   For example, if you had these two files:
--   
--   <pre>
--   $ cat foo
--   ./bar
--   </pre>
--   
--   <pre>
--   $ cat bar
--   ./foo
--   </pre>
--   
--   ... Dhall would throw the following exception if you tried to import
--   <tt>foo</tt>:
--   
--   <pre>
--   $ dhall
--   ./foo
--   ^D
--   ↳ ./foo
--     ↳ ./bar
--   
--   Cyclic import: ./foo
--   </pre>
--   
--   You can also import expressions hosted on network endpoints. Just use
--   the URL
--   
--   <pre>
--   http://host[:port]/path
--   </pre>
--   
--   The compiler expects the downloaded expressions to be in the same
--   format as local files, specifically UTF8-encoded source code text.
--   
--   For example, if our <tt>id</tt> expression were hosted at
--   <tt><a>http://example.com/id</a></tt>, then we would embed the
--   expression within our code using:
--   
--   <pre>
--   http://example.com/id
--   </pre>
--   
--   You can also import expressions stored within environment variables
--   using <tt>env:NAME</tt>, where <tt>NAME</tt> is the name of the
--   environment variable. For example:
--   
--   <pre>
--   $ export FOO=1
--   $ export BAR='"Hi"'
--   $ export BAZ='λ(x : Bool) → x == False'
--   $ dhall &lt;&lt;&lt; "{ foo = env:FOO , bar = env:BAR , baz = env:BAZ }"
--   { bar : Text, baz : ∀(x : Bool) → Bool, foo : Integer }
--   
--   { bar = "Hi", baz = λ(x : Bool) → x == False, foo = 1 }
--   </pre>
--   
--   If you wish to import the raw contents of an impoert as <tt>Text</tt>
--   then add <tt>as Text</tt> to the end of the import:
--   
--   <pre>
--   $ dhall &lt;&lt;&lt; "http://example.com as Text"
--   Text
--   
--   "&lt;!doctype html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Example Domain&lt;/title&gt;\n\n    &lt;meta
--    charset=\"utf-8\" /&gt;\n    &lt;meta http-equiv=\"Content-type\" content=\"text/html
--   ; charset=utf-8\" /&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width,
--   initial-scale=1\" /&gt;\n    &lt;style type=\"text/css\"&gt;\n    body {\n        backgro
--   und-color: #f0f0f2;\n        margin: 0;\n        padding: 0;\n        font-famil
--   y: \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n        \n
--      }\n    div {\n        width: 600px;\n        margin: 5em auto;\n        paddi
--   ng: 50px;\n        background-color: #fff;\n        border-radius: 1em;\n    }\n
--       a:link, a:visited {\n        color: #38488f;\n        text-decoration: none;
--   \n    }\n    @media (max-width: 700px) {\n        body {\n            background
--   -color: #fff;\n        }\n        div {\n            width: auto;\n            m
--   argin: 0 auto;\n            border-radius: 0;\n            padding: 1em;\n
--     }\n    }\n    &lt;/style&gt;    \n&lt;/head&gt;\n\n&lt;body&gt;\n&lt;div&gt;\n    &lt;h1&gt;Example Domain&lt;/
--   h1&gt;\n    &lt;p&gt;This domain is established to be used for illustrative examples in d
--   ocuments. You may use this\n    domain in examples without prior coordination or
--    asking for permission.&lt;/p&gt;\n    &lt;p&gt;&lt;a href=\"http://www.iana.org/domains/exampl
--   e\"&gt;More information...&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n"
--   </pre>
module Dhall.Import

-- | Parse an expression from a <a>Import</a> containing a Dhall program
exprFromImport :: Import -> StateT Status IO (Expr Src Import)

-- | Resolve all imports within an expression
load :: Expr Src Import -> IO (Expr Src X)

-- | Resolve all imports within an expression using a custom typing context
--   and <a>Import</a>-resolving callback in arbitrary <a>MonadCatch</a>
--   monad.
loadWith :: MonadCatch m => (Import -> StateT Status m (Expr Src Import)) -> Context (Expr Src X) -> Normalizer X -> Expr Src Import -> m (Expr Src X)

-- | Resolve all imports within an expression using a custom typing
--   context.
--   
--   <pre>
--   load = loadWithContext Dhall.Context.empty
--   </pre>
loadWithContext :: Context (Expr Src X) -> Normalizer X -> Expr Src Import -> IO (Expr Src X)

-- | Hash a fully resolved expression
hashExpression :: Expr s X -> (Digest SHA256)

-- | Convenience utility to hash a fully resolved expression and return the
--   base-16 encoded hash with the <tt>sha256:</tt> prefix
--   
--   In other words, the output of this function can be pasted into Dhall
--   source code to add an integrity check to an import
hashExpressionToCode :: Expr s X -> Text

-- | State threaded throughout the import process
data Status
Status :: [Import] -> Map Import (Expr Src X) -> Maybe Dynamic -> Status

-- | Stack of <a>Import</a>s that we've imported along the way to get to
--   the current point
[_stack] :: Status -> [Import]

-- | Cache of imported expressions in order to avoid importing the same
--   expression twice with different values
[_cache] :: Status -> Map Import (Expr Src X)

-- | Cache for the HTTP <tt>Manager</tt> so that we only acquire it once
[_manager] :: Status -> Maybe Dynamic

-- | Default starting <a>Status</a>
emptyStatus :: Status

-- | An import failed because of a cycle in the import graph
newtype Cycle
Cycle :: Import -> Cycle

-- | The offending cyclic import
[cyclicImport] :: Cycle -> Import

-- | Dhall tries to ensure that all expressions hosted on network endpoints
--   are weakly referentially transparent, meaning roughly that any two
--   clients will compile the exact same result given the same URL.
--   
--   To be precise, a strong interpretaton of referential transparency
--   means that if you compiled a URL you could replace the expression
--   hosted at that URL with the compiled result. Let's call this "static
--   linking". Dhall (very intentionally) does not satisfy this stronger
--   interpretation of referential transparency since "statically linking"
--   an expression (i.e. permanently resolving all imports) means that the
--   expression will no longer update if its dependencies change.
--   
--   In general, either interpretation of referential transparency is not
--   enforceable in a networked context since one can easily violate
--   referential transparency with a custom DNS, but Dhall can still try to
--   guard against common unintentional violations. To do this, Dhall
--   enforces that a non-local import may not reference a local import.
--   
--   Local imports are defined as:
--   
--   <ul>
--   <li>A file</li>
--   <li>A URL with a host of <tt>localhost</tt> or <tt>127.0.0.1</tt></li>
--   </ul>
--   
--   All other imports are defined to be non-local
newtype ReferentiallyOpaque
ReferentiallyOpaque :: Import -> ReferentiallyOpaque

-- | The offending opaque import
[opaqueImport] :: ReferentiallyOpaque -> Import

-- | Extend another exception with the current import stack
data Imported e
Imported :: [Import] -> e -> Imported e

-- | Imports resolved so far, in reverse order
[importStack] :: Imported e -> [Import]

-- | The nested exception
[nested] :: Imported e -> e

-- | Wrapper around <tt>HttpException</tt>s with a prettier <a>Show</a>
--   instance.
--   
--   In order to keep the library API constant even when the
--   <tt>with-http</tt> Cabal flag is disabled the pretty error message is
--   pre-rendered and the real <tt>HttpExcepion</tt> is stored in a
--   <a>Dynamic</a>
data PrettyHttpException
PrettyHttpException :: String -> Dynamic -> PrettyHttpException

-- | Exception thrown when an imported file is missing
data MissingFile
MissingFile :: FilePath -> MissingFile

-- | Exception thrown when an environment variable is missing
newtype MissingEnvironmentVariable
MissingEnvironmentVariable :: Text -> MissingEnvironmentVariable
[name] :: MissingEnvironmentVariable -> Text

-- | List of Exceptions we encounter while resolving Import Alternatives
newtype MissingImports
MissingImports :: [SomeException] -> MissingImports
instance GHC.Exception.Exception Dhall.Import.HashMismatch
instance GHC.Show.Show Dhall.Import.HashMismatch
instance Dhall.Import.Canonicalize Dhall.Core.Directory
instance Dhall.Import.Canonicalize Dhall.Core.File
instance Dhall.Import.Canonicalize Dhall.Core.ImportType
instance Dhall.Import.Canonicalize Dhall.Core.ImportHashed
instance Dhall.Import.Canonicalize Dhall.Core.Import
instance GHC.Exception.Exception Dhall.Import.CannotImportHTTPURL
instance GHC.Show.Show Dhall.Import.CannotImportHTTPURL
instance GHC.Exception.Exception Dhall.Import.MissingImports
instance GHC.Show.Show Dhall.Import.MissingImports
instance GHC.Exception.Exception Dhall.Import.MissingEnvironmentVariable
instance GHC.Show.Show Dhall.Import.MissingEnvironmentVariable
instance GHC.Exception.Exception Dhall.Import.MissingFile
instance GHC.Show.Show Dhall.Import.MissingFile
instance GHC.Exception.Exception e => GHC.Exception.Exception (Dhall.Import.Imported e)
instance GHC.Show.Show e => GHC.Show.Show (Dhall.Import.Imported e)
instance GHC.Exception.Exception Dhall.Import.ReferentiallyOpaque
instance GHC.Show.Show Dhall.Import.ReferentiallyOpaque
instance GHC.Exception.Exception Dhall.Import.Cycle
instance GHC.Show.Show Dhall.Import.Cycle

module Dhall.Freeze
freeze :: Maybe FilePath -> IO ()
hashImport :: Import -> IO Import

module Dhall.Hash
hash :: IO ()


-- | Please read the <a>Dhall.Tutorial</a> module, which contains a
--   tutorial explaining how to use the language, the compiler, and this
--   library
module Dhall

-- | Type-check and evaluate a Dhall program, decoding the result into
--   Haskell
--   
--   The first argument determines the type of value that you decode:
--   
--   <pre>
--   &gt;&gt;&gt; input integer "+2"
--   2
--   
--   &gt;&gt;&gt; input (vector double) "[1.0, 2.0]"
--   [1.0,2.0]
--   </pre>
--   
--   Use <a>auto</a> to automatically select which type to decode based on
--   the inferred return type:
--   
--   <pre>
--   &gt;&gt;&gt; input auto "True" :: IO Bool
--   True
--   </pre>
input :: Type a -> Text -> IO a
inputFrom :: FilePath -> Type a -> Text -> IO a

-- | Extend <a>input</a> with a custom typing context and normalization
--   process.
inputWith :: Type a -> Context (Expr Src X) -> Normalizer X -> Text -> IO a

-- | Extend <a>inputFrom</a> with a custom typing context and normalization
--   process.
inputFromWith :: FilePath -> Type a -> Context (Expr Src X) -> Normalizer X -> Text -> IO a

-- | Similar to <a>input</a>, but without interpreting the Dhall
--   <a>Expr</a> into a Haskell type.
inputExpr :: Text -> IO (Expr Src X)

-- | Extend <a>inputExpr</a> with a custom typing context and normalization
--   process.
inputExprWith :: Context (Expr Src X) -> Normalizer X -> Text -> IO (Expr Src X)

-- | Use this to provide more detailed error messages
--   
--   <pre>
--   &gt; input auto "True" :: IO Integer
--    *** Exception: Error: Expression doesn't match annotation
--   
--    True : Integer
--   
--    (input):1:1
--   </pre>
--   
--   <pre>
--   &gt; detailed (input auto "True") :: IO Integer
--    *** Exception: Error: Expression doesn't match annotation
--   
--    Explanation: You can annotate an expression with its type or kind using the
--    ❰:❱ symbol, like this:
--   
--   
--        ┌───────┐
--        │ x : t │  ❰x❱ is an expression and ❰t❱ is the annotated type or kind of ❰x❱
--        └───────┘
--   
--    The type checker verifies that the expression's type or kind matches the
--    provided annotation
--   
--    For example, all of the following are valid annotations that the type checker
--    accepts:
--   
--   
--        ┌─────────────┐
--        │ 1 : Natural │  ❰1❱ is an expression that has type ❰Natural❱, so the type
--        └─────────────┘  checker accepts the annotation
--   
--   
--        ┌───────────────────────┐
--        │ Natural/even 2 : Bool │  ❰Natural/even 2❱ has type ❰Bool❱, so the type
--        └───────────────────────┘  checker accepts the annotation
--   
--   
--        ┌────────────────────┐
--        │ List : Type → Type │  ❰List❱ is an expression that has kind ❰Type → Type❱,
--        └────────────────────┘  so the type checker accepts the annotation
--   
--   
--        ┌──────────────────┐
--        │ List Text : Type │  ❰List Text❱ is an expression that has kind ❰Type❱, so
--        └──────────────────┘  the type checker accepts the annotation
--   
--   
--    However, the following annotations are not valid and the type checker will
--    reject them:
--   
--   
--        ┌──────────┐
--        │ 1 : Text │  The type checker rejects this because ❰1❱ does not have type
--        └──────────┘  ❰Text❱
--   
--   
--        ┌─────────────┐
--        │ List : Type │  ❰List❱ does not have kind ❰Type❱
--        └─────────────┘
--   
--   
--    You or the interpreter annotated this expression:
--   
--    ↳ True
--   
--    ... with this type or kind:
--   
--    ↳ Integer
--   
--    ... but the inferred type or kind of the expression is actually:
--   
--    ↳ Bool
--   
--    Some common reasons why you might get this error:
--   
--    ● The Haskell Dhall interpreter implicitly inserts a top-level annotation
--      matching the expected type
--   
--      For example, if you run the following Haskell code:
--   
--   
--        ┌───────────────────────────────┐
--        │ &gt;&gt;&gt; input auto "1" :: IO Text │
--        └───────────────────────────────┘
--   
--   
--      ... then the interpreter will actually type check the following annotated
--      expression:
--   
--   
--        ┌──────────┐
--        │ 1 : Text │
--        └──────────┘
--   
--   
--      ... and then type-checking will fail
--   
--    ────────────────────────────────────────────────────────────────────────────────
--   
--    True : Integer
--   
--    (input):1:1
--   </pre>
detailed :: IO a -> IO a

-- | A <tt>(Type a)</tt> represents a way to marshal a value of type
--   <tt>'a'</tt> from Dhall into Haskell
--   
--   You can produce <a>Type</a>s either explicitly:
--   
--   <pre>
--   example :: Type (Vector Text)
--   example = vector text
--   </pre>
--   
--   ... or implicitly using <a>auto</a>:
--   
--   <pre>
--   example :: Type (Vector Text)
--   example = auto
--   </pre>
--   
--   You can consume <a>Type</a>s using the <a>input</a> function:
--   
--   <pre>
--   input :: Type a -&gt; Text -&gt; IO a
--   </pre>
data Type a
Type :: Expr Src X -> Maybe a -> Expr Src X -> Type a

-- | Extracts Haskell value from the Dhall expression
[extract] :: Type a -> Expr Src X -> Maybe a

-- | Dhall type of the Haskell value
[expected] :: Type a -> Expr Src X

-- | The <a>RecordType</a> applicative functor allows you to build a
--   <a>Type</a> parser from a Dhall record.
--   
--   For example, let's take the following Haskell data type:
--   
--   <pre>
--   data Project = Project
--     { projectName :: Text
--     , projectDescription :: Text
--     , projectStars :: Natural
--     }
--   </pre>
--   
--   And assume that we have the following Dhall record that we would like
--   to parse as a <tt>Project</tt>:
--   
--   <pre>
--   { name =
--       "dhall-haskell"
--   , description =
--       "A configuration language guaranteed to terminate"
--   , stars =
--       289
--   }
--   </pre>
--   
--   Our parser has type <a>Type</a> <tt>Project</tt>, but we can't build
--   that out of any smaller parsers, as <a>Type</a>s cannot be combined
--   (they are only <a>Functor</a>s). However, we can use a
--   <a>RecordType</a> to build a <a>Type</a> for <tt>Project</tt>:
--   
--   <pre>
--   project :: Type Project
--   project =
--     record
--       ( Project &lt;$&gt; field "name" string
--                 &lt;*&gt; field "description" string
--                 &lt;*&gt; field "stars" natural
--       )
--   </pre>
newtype RecordType a
RecordType :: (Product (Const (InsOrdHashMap Text (Expr Src X))) (Compose ((->) (Expr Src X)) Maybe) a) -> RecordType a

-- | An <tt>(InputType a)</tt> represents a way to marshal a value of type
--   <tt>'a'</tt> from Haskell into Dhall
data InputType a
InputType :: a -> Expr Src X -> Expr Src X -> InputType a

-- | Embeds a Haskell value as a Dhall expression
[embed] :: InputType a -> a -> Expr Src X

-- | Dhall type of the Haskell value
[declared] :: InputType a -> Expr Src X

-- | Any value that implements <a>Interpret</a> can be automatically
--   decoded based on the inferred return type of <a>input</a>
--   
--   <pre>
--   &gt;&gt;&gt; input auto "[1, 2, 3]" :: IO (Vector Natural)
--   [1,2,3]
--   </pre>
--   
--   This class auto-generates a default implementation for records that
--   implement <a>Generic</a>. This does not auto-generate an instance for
--   recursive types.
class Interpret a
autoWith :: Interpret a => InterpretOptions -> Type a
autoWith :: (Interpret a, Generic a, GenericInterpret (Rep a)) => InterpretOptions -> Type a

-- | Every <a>Type</a> must obey the contract that if an expression's type
--   matches the the <a>expected</a> type then the <a>extract</a> function
--   must succeed. If not, then this exception is thrown
--   
--   This exception indicates that an invalid <a>Type</a> was provided to
--   the <a>input</a> function
data InvalidType
InvalidType :: InvalidType

-- | Use the default options for interpreting a configuration file
--   
--   <pre>
--   auto = autoWith defaultInterpretOptions
--   </pre>
auto :: Interpret a => Type a

-- | <a>genericAuto</a> is the default implementation for <a>auto</a> if
--   you derive <a>Interpret</a>. The difference is that you can use
--   <a>genericAuto</a> without having to explicitly provide an
--   <a>Interpret</a> instance for a type as long as the type derives
--   <a>Generic</a>
genericAuto :: (Generic a, GenericInterpret (Rep a)) => Type a

-- | Use these options to tweak how Dhall derives a generic implementation
--   of <a>Interpret</a>
data InterpretOptions
InterpretOptions :: Text -> Text -> Text -> Text -> InterpretOptions

-- | Function used to transform Haskell field names into their
--   corresponding Dhall field names
[fieldModifier] :: InterpretOptions -> Text -> Text

-- | Function used to transform Haskell constructor names into their
--   corresponding Dhall alternative names
[constructorModifier] :: InterpretOptions -> Text -> Text

-- | Default interpret options, which you can tweak or override, like this:
--   
--   <pre>
--   autoWith
--       (defaultInterpretOptions { fieldModifier = Data.Text.Lazy.dropWhile (== '_') })
--   </pre>
defaultInterpretOptions :: InterpretOptions

-- | Decode a <a>Bool</a>
--   
--   <pre>
--   &gt;&gt;&gt; input bool "True"
--   True
--   </pre>
bool :: Type Bool

-- | Decode a <a>Natural</a>
--   
--   <pre>
--   &gt;&gt;&gt; input natural "42"
--   42
--   </pre>
natural :: Type Natural

-- | Decode an <a>Integer</a>
--   
--   <pre>
--   &gt;&gt;&gt; input integer "+42"
--   42
--   </pre>
integer :: Type Integer

-- | Decode a <a>Scientific</a>
--   
--   <pre>
--   &gt;&gt;&gt; input scientific "1e1000000000"
--   1.0e1000000000
--   </pre>
scientific :: Type Scientific

-- | Decode a <a>Double</a>
--   
--   <pre>
--   &gt;&gt;&gt; input double "42.0"
--   42.0
--   </pre>
double :: Type Double

-- | Decode lazy <a>Text</a>
--   
--   <pre>
--   &gt;&gt;&gt; input lazyText "\"Test\""
--   "Test"
--   </pre>
lazyText :: Type Text

-- | Decode strict <a>Text</a>
--   
--   <pre>
--   &gt;&gt;&gt; input strictText "\"Test\""
--   "Test"
--   </pre>
strictText :: Type Text

-- | Decode a <a>Maybe</a>
--   
--   <pre>
--   &gt;&gt;&gt; input (maybe natural) "[1] : Optional Natural"
--   Just 1
--   </pre>
maybe :: Type a -> Type (Maybe a)

-- | Decode a <a>Seq</a> - &gt;&gt;&gt; input (sequence natural) "[1, 2,
--   3]" fromList [1,2,3]
sequence :: Type a -> Type (Seq a)

-- | Decode a list
--   
--   <pre>
--   &gt;&gt;&gt; input (list natural) "[1, 2, 3]"
--   [1,2,3]
--   </pre>
list :: Type a -> Type [a]

-- | Decode a <a>Vector</a>
--   
--   <pre>
--   &gt;&gt;&gt; input (vector natural) "[1, 2, 3]"
--   [1,2,3]
--   </pre>
vector :: Type a -> Type (Vector a)

-- | Decode `()` from an empty record.
--   
--   <pre>
--   &gt;&gt;&gt; input unit "{=}"  -- GHC doesn't print the result if it is @()@
--   </pre>
unit :: Type ()

-- | Decode a <a>String</a>
--   
--   <pre>
--   &gt;&gt;&gt; input string "\"ABC\""
--   "ABC"
--   </pre>
--   
--   "
string :: Type String

-- | Given a pair of <a>Type</a>s, decode a tuple-record into their
--   pairing.
--   
--   <pre>
--   &gt;&gt;&gt; input (pair natural bool) "{ _1 = 42, _2 = False }"
--   (42,False)
--   </pre>
pair :: Type a -> Type b -> Type (a, b)

-- | Run a <a>RecordType</a> parser to build a <a>Type</a> parser.
record :: RecordType a -> Type a

-- | Parse a single field of a record.
field :: Text -> Type a -> RecordType a

-- | This is the underlying class that powers the <a>Interpret</a> class's
--   support for automatically deriving a generic implementation
class GenericInterpret f
genericAutoWith :: GenericInterpret f => InterpretOptions -> State Int (Type (f a))

-- | This is the underlying class that powers the <a>Interpret</a> class's
--   support for automatically deriving a generic implementation
class GenericInject f
genericInjectWith :: GenericInject f => InterpretOptions -> State Int (InputType (f a))

-- | This class is used by <a>Interpret</a> instance for functions:
--   
--   <pre>
--   instance (Inject a, Interpret b) =&gt; Interpret (a -&gt; b)
--   </pre>
--   
--   You can convert Dhall functions with "simple" inputs (i.e. instances
--   of this class) into Haskell functions. This works by:
--   
--   <ul>
--   <li>Marshaling the input to the Haskell function into a Dhall
--   expression (i.e. <tt>x :: Expr Src X</tt>)</li>
--   <li>Applying the Dhall function (i.e. <tt>f :: Expr Src X</tt>) to the
--   Dhall input (i.e. <tt>App f x</tt>)</li>
--   <li>Normalizing the syntax tree (i.e. <tt>normalize (App f
--   x)</tt>)</li>
--   <li>Marshaling the resulting Dhall expression back into a Haskell
--   value</li>
--   </ul>
class Inject a
injectWith :: Inject a => InterpretOptions -> InputType a
injectWith :: (Inject a, Generic a, GenericInject (Rep a)) => InterpretOptions -> InputType a

-- | Use the default options for injecting a value
--   
--   <pre>
--   inject = inject defaultInterpretOptions
--   </pre>
inject :: Inject a => InputType a

-- | Use this function to extract Haskell values directly from Dhall AST.
--   The intended use case is to allow easy extraction of Dhall values for
--   making the function <a>normalizeWith</a> easier to use.
--   
--   For other use cases, use <a>input</a> from <tt>Dhall</tt> module. It
--   will give you a much better user experience.
rawInput :: Alternative f => Type a -> Expr s X -> f a

-- | Type representing arbitrary-precision non-negative integers.
--   
--   <pre>
--   &gt;&gt;&gt; 2^20 :: Natural
--   1267650600228229401496703205376
--   </pre>
--   
--   Operations whose result would be negative <tt><tt>throw</tt>
--   (<tt>Underflow</tt> :: <tt>ArithException</tt>)</tt>,
--   
--   <pre>
--   &gt;&gt;&gt; -1 :: Natural
--   *** Exception: arithmetic underflow
--   </pre>
data Natural

-- | General-purpose finite sequences.
data Seq a

-- | A space efficient, packed, unboxed Unicode text type.
data Text

-- | Boxed vectors, supporting efficient slicing.
data Vector a

-- | Representable types of kind <tt>*</tt>. This class is derivable in GHC
--   with the <tt>DeriveGeneric</tt> flag on.
--   
--   A <a>Generic</a> instance must satisfy the following laws:
--   
--   <pre>
--   <a>from</a> . <a>to</a> ≡ <tt>id</tt>
--   <a>to</a> . <a>from</a> ≡ <tt>id</tt>
--   </pre>
class Generic a
instance GHC.Base.Applicative Dhall.RecordType
instance GHC.Base.Functor Dhall.RecordType
instance GHC.Base.Functor Dhall.Type
instance (Dhall.Inject a, Dhall.Interpret b) => Dhall.Interpret (a -> b)
instance Dhall.Inject GHC.Types.Bool
instance Dhall.Inject Data.Text.Internal.Lazy.Text
instance Dhall.Inject Data.Text.Internal.Text
instance Dhall.Inject GHC.Natural.Natural
instance Dhall.Inject GHC.Integer.Type.Integer
instance Dhall.Inject GHC.Types.Int
instance Dhall.Inject GHC.Word.Word8
instance Dhall.Inject GHC.Word.Word16
instance Dhall.Inject GHC.Word.Word32
instance Dhall.Inject GHC.Word.Word64
instance Dhall.Inject Data.Scientific.Scientific
instance Dhall.Inject GHC.Types.Double
instance Dhall.Inject ()
instance Dhall.Inject a => Dhall.Inject (GHC.Base.Maybe a)
instance Dhall.Inject a => Dhall.Inject (Data.Sequence.Internal.Seq a)
instance Dhall.Inject a => Dhall.Inject [a]
instance Dhall.Inject a => Dhall.Inject (Data.Vector.Vector a)
instance Dhall.Inject a => Dhall.Inject (Data.Set.Internal.Set a)
instance (Dhall.Inject a, Dhall.Inject b) => Dhall.Inject (a, b)
instance (GHC.Generics.Selector s, Dhall.Inject a) => Dhall.GenericInject (GHC.Generics.M1 GHC.Generics.S s (GHC.Generics.K1 i a))
instance Dhall.GenericInject f => Dhall.GenericInject (GHC.Generics.M1 GHC.Generics.D d f)
instance Dhall.GenericInject f => Dhall.GenericInject (GHC.Generics.M1 GHC.Generics.C c f)
instance (GHC.Generics.Constructor c1, GHC.Generics.Constructor c2, Dhall.GenericInject f1, Dhall.GenericInject f2) => Dhall.GenericInject (GHC.Generics.M1 GHC.Generics.C c1 f1 GHC.Generics.:+: GHC.Generics.M1 GHC.Generics.C c2 f2)
instance (GHC.Generics.Constructor c, Dhall.GenericInject (f GHC.Generics.:+: g), Dhall.GenericInject h) => Dhall.GenericInject ((f GHC.Generics.:+: g) GHC.Generics.:+: GHC.Generics.M1 GHC.Generics.C c h)
instance (GHC.Generics.Constructor c, Dhall.GenericInject f, Dhall.GenericInject (g GHC.Generics.:+: h)) => Dhall.GenericInject (GHC.Generics.M1 GHC.Generics.C c f GHC.Generics.:+: (g GHC.Generics.:+: h))
instance (Dhall.GenericInject (f GHC.Generics.:+: g), Dhall.GenericInject (h GHC.Generics.:+: i)) => Dhall.GenericInject ((f GHC.Generics.:+: g) GHC.Generics.:+: (h GHC.Generics.:+: i))
instance (Dhall.GenericInject f, Dhall.GenericInject g) => Dhall.GenericInject (f GHC.Generics.:*: g)
instance Dhall.GenericInject GHC.Generics.U1
instance Data.Functor.Contravariant.Contravariant Dhall.InputType
instance Dhall.Interpret GHC.Types.Bool
instance Dhall.Interpret GHC.Natural.Natural
instance Dhall.Interpret GHC.Integer.Type.Integer
instance Dhall.Interpret Data.Scientific.Scientific
instance Dhall.Interpret GHC.Types.Double
instance Dhall.Interpret [GHC.Types.Char]
instance Dhall.Interpret Data.Text.Internal.Lazy.Text
instance Dhall.Interpret Data.Text.Internal.Text
instance Dhall.Interpret a => Dhall.Interpret (GHC.Base.Maybe a)
instance Dhall.Interpret a => Dhall.Interpret (Data.Sequence.Internal.Seq a)
instance Dhall.Interpret a => Dhall.Interpret [a]
instance Dhall.Interpret a => Dhall.Interpret (Data.Vector.Vector a)
instance (Dhall.Interpret a, Dhall.Interpret b) => Dhall.Interpret (a, b)
instance (GHC.Generics.Selector s, Dhall.Interpret a) => Dhall.GenericInterpret (GHC.Generics.M1 GHC.Generics.S s (GHC.Generics.K1 i a))
instance Dhall.GenericInterpret f => Dhall.GenericInterpret (GHC.Generics.M1 GHC.Generics.D d f)
instance Dhall.GenericInterpret GHC.Generics.V1
instance (GHC.Generics.Constructor c1, GHC.Generics.Constructor c2, Dhall.GenericInterpret f1, Dhall.GenericInterpret f2) => Dhall.GenericInterpret (GHC.Generics.M1 GHC.Generics.C c1 f1 GHC.Generics.:+: GHC.Generics.M1 GHC.Generics.C c2 f2)
instance (GHC.Generics.Constructor c, Dhall.GenericInterpret (f GHC.Generics.:+: g), Dhall.GenericInterpret h) => Dhall.GenericInterpret ((f GHC.Generics.:+: g) GHC.Generics.:+: GHC.Generics.M1 GHC.Generics.C c h)
instance (GHC.Generics.Constructor c, Dhall.GenericInterpret f, Dhall.GenericInterpret (g GHC.Generics.:+: h)) => Dhall.GenericInterpret (GHC.Generics.M1 GHC.Generics.C c f GHC.Generics.:+: (g GHC.Generics.:+: h))
instance (Dhall.GenericInterpret (f GHC.Generics.:+: g), Dhall.GenericInterpret (h GHC.Generics.:+: i)) => Dhall.GenericInterpret ((f GHC.Generics.:+: g) GHC.Generics.:+: (h GHC.Generics.:+: i))
instance Dhall.GenericInterpret f => Dhall.GenericInterpret (GHC.Generics.M1 GHC.Generics.C c f)
instance Dhall.GenericInterpret GHC.Generics.U1
instance (Dhall.GenericInterpret f, Dhall.GenericInterpret g) => Dhall.GenericInterpret (f GHC.Generics.:*: g)
instance GHC.Show.Show Dhall.InvalidType
instance GHC.Exception.Exception Dhall.InvalidType


-- | Dhall is a programming language specialized for configuration files.
--   This module contains a tutorial explaning how to author configuration
--   files using this language
module Dhall.Tutorial


-- | This module provides <a>staticDhallExpression</a> which can be used to
--   resolve all of an expression’s imports at compile time, allowing one
--   to reference Dhall expressions from Haskell without having a runtime
--   dependency on the location of Dhall files.
--   
--   For example, given a file “Some/Type.dhall” containing
--   
--   <a>: Natural | Other : ../Other/Type.dhall</a>
--   
--   rather than duplicating the AST manually in a Haskell <a>Type</a>, you
--   can do
--   
--   Dhall.Type (case UnionLit <a>This</a> _ _ -&gt; ... UnionLit
--   <a>Other</a> _ _ -&gt; ...) $(staticDhallExpression
--   "..<i>..</i>Some/Type.dhall")
--   
--   This would create the Dhall Expr AST from the <a>dhall</a> file at
--   compile time with all imports resolved, making it easy to keep your
--   Dhall configs and Haskell interpreters in sync.
module Dhall.TH

-- | This fully resolves, type checks, and normalizes the expression, so
--   the resulting AST is self-contained.
staticDhallExpression :: Text -> Q Exp

module Dhall.Repl
repl :: Bool -> IO ()

module Dhall.Main
parseOptions :: Parser Options
parserInfoOptions :: ParserInfo Options
command :: Options -> IO ()
main :: IO ()
instance GHC.Exception.Exception Dhall.Main.ImportResolutionDisabled
instance GHC.Show.Show Dhall.Main.ImportResolutionDisabled
