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


-- | Compile Dhall to Bash
--   
--   Use this package if you want to compile Dhall expressions to Bash. You
--   can use this package as a library or an executable:
--   
--   <ul>
--   <li>See the <a>Dhall.Bash</a> module if you want to use this package
--   as a library</li>
--   <li>Use the <tt>dhall-to-bash</tt> if you want an executable</li>
--   </ul>
--   
--   The <a>Dhall.Bash</a> module also contains instructions for how to use
--   this package
@package dhall-bash
@version 1.0.18


-- | This library exports two utilities for compiling Dhall expressions to
--   Bash:
--   
--   <ul>
--   <li><a>dhallToExpression</a>, which emits a Bash expression (i.e. a
--   valid right-hand side for an assignment)</li>
--   <li><a>dhallToStatement</a>, which emits a Bash <tt>declare</tt> or
--   <tt>unset</tt> statement suitable for use with <tt>eval</tt></li>
--   </ul>
--   
--   <a>dhallToExpression</a> only supports the conversion of primitive
--   values, such as:
--   
--   <ul>
--   <li><tt>Bool</tt> - which translates to a string that is either
--   <tt>"true"</tt> or <tt>"false"</tt></li>
--   <li><tt>Natural</tt> - which translates to a Bash integer</li>
--   <li><tt>Integer</tt> - which translates to a Bash integer</li>
--   <li><tt>Text</tt> - which translates to a Bash string (properly
--   escaped if necessary)</li>
--   </ul>
--   
--   The <tt>dhall-to-bash</tt> executable by default tries to compile
--   Dhall expressions to Bash expressions using the
--   <a>dhallToExpression</a> function. For example:
--   
--   <pre>
--   $ dhall-to-bash &lt;&lt;&lt; 'True'
--   true
--   $ dhall-to-bash &lt;&lt;&lt; 'False'
--   false
--   $ dhall-to-bash &lt;&lt;&lt; '1'
--   1
--   $ dhall-to-bash &lt;&lt;&lt; '+1'
--   1
--   $ dhall-to-bash &lt;&lt;&lt; '"ABC"'
--   ABC
--   $ dhall-to-bash &lt;&lt;&lt; '" X "'
--   $' X '
--   $ dhall-to-bash &lt;&lt;&lt; 'Natural/even +100'
--   true
--   </pre>
--   
--   The output of <a>dhallToExpression</a> is a valid Bash expression that
--   can be embedded anywhere Bash expressions are valid, such as the
--   right-hand side of an assignment statement:
--   
--   <pre>
--   $ FOO=$(dhall-to-bash &lt;&lt;&lt; 'List/length Natural [1, 2, 3]')
--   $ echo "${FOO}"
--   3
--   </pre>
--   
--   <a>dhallToStatement</a> supports a wider range of expressions by also
--   adding support for:
--   
--   <ul>
--   <li><tt>Optional</tt> - which translates to a variable which is either
--   set or unset</li>
--   <li><tt>List</tt> - which translates to a Bash array</li>
--   <li>records - which translate to Bash associative arrays</li>
--   </ul>
--   
--   The <tt>dhall-to-bash</tt> executable can emit a statement instead of
--   an expression if you add the <tt>--declare</tt> flag specifying which
--   variable to set or unset. For example:
--   
--   <pre>
--   $ dhall-to-bash --declare FOO &lt;&lt;&lt; 'None Natural'
--   unset FOO
--   $ dhall-to-bash --declare FOO &lt;&lt;&lt; 'Some 1'
--   declare -r -i FOO=1
--   $ dhall-to-bash --declare FOO &lt;&lt;&lt; 'Some (Some 1)'
--   declare -r -i FOO=1
--   $ dhall-to-bash --declare FOO &lt;&lt;&lt; 'Some (None Natural)'
--   unset FOO
--   $ dhall-to-bash --declare FOO &lt;&lt;&lt; '[1, 2, 3]'
--   declare -r -a FOO=(1 2 3)
--   $ dhall-to-bash --declare FOO &lt;&lt;&lt; '{ bar = 1, baz = True }'
--   declare -r -A FOO=([bar]=1 [baz]=true)
--   </pre>
--   
--   The output of <a>dhallToExpression</a> is either a <tt>declare</tt> or
--   <tt>unset</tt> Bash statement that you can pass to <tt>eval</tt>:
--   
--   <pre>
--   $ eval $(dhall-to-bash --declare FOO &lt;&lt;&lt; '{ bar = 1, baz = True }')
--   $ echo "${FOO[bar]}"
--   1
--   $ echo "${FOO[baz]}"
--   true
--   </pre>
--   
--   <tt>dhall-to-bash</tt> declares variables read-only (i.e. <tt>-r</tt>)
--   to prevent you from accidentally overwriting, deleting or mutating
--   variables:
--   
--   <pre>
--   $ eval $(dist/build/dhall-to-bash/dhall-to-bash --declare BAR &lt;&lt;&lt; '1')
--   $ echo "${BAR"}
--   1
--   $ unset BAR
--   bash: unset: BAR: cannot unset: readonly variable
--   $ eval $(dist/build/dhall-to-bash/dhall-to-bash --declare BAR &lt;&lt;&lt; '2')
--   bash: declare: BAR: readonly variable
--   </pre>
module Dhall.Bash

-- | Compile a Dhall expression to a Bash expression
--   
--   This only supports:
--   
--   <ul>
--   <li><tt>Bool</tt>s</li>
--   <li><tt>Natural</tt>s</li>
--   <li><tt>Integer</tt>s</li>
--   <li><tt>Text</tt>s</li>
--   </ul>
dhallToExpression :: Expr s X -> Either ExpressionError ByteString

-- | Compile a Dhall expression to a Bash statement that <tt>declare</tt>s
--   or <tt>unset</tt>s a a variable of your choice
--   
--   This only supports:
--   
--   <ul>
--   <li><tt>Bool</tt>s</li>
--   <li><tt>Natural</tt>s</li>
--   <li><tt>Integer</tt>s</li>
--   <li><tt>Text</tt>s</li>
--   <li><tt>Optional</tt>s</li>
--   <li><tt>List</tt>s</li>
--   <li>records</li>
--   </ul>
dhallToStatement :: Expr s X -> ByteString -> Either StatementError ByteString

-- | This is the exception type for errors that might arise when
--   translating Dhall expressions to Bash expressions
--   
--   Because the majority of Dhall language features do not easily
--   translate to Bash this just returns the expression that failed
data ExpressionError
UnsupportedExpression :: Expr X X -> ExpressionError

-- | This is the exception type for errors that might arise when
--   translating Dhall expressions to Bash statements
--   
--   Because the majority of Dhall language features do not easily
--   translate to Bash this just returns the expression that failed
data StatementError
UnsupportedStatement :: Expr X X -> StatementError
UnsupportedSubexpression :: Expr X X -> StatementError
instance GHC.Show.Show Dhall.Bash.ExpressionError
instance GHC.Exception.Type.Exception Dhall.Bash.ExpressionError
instance GHC.Show.Show Dhall.Bash.StatementError
instance GHC.Exception.Type.Exception Dhall.Bash.StatementError
