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


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


-- | This library only exports a single <a>dhallToJSON</a> function for
--   translating a Dhall syntax tree to a JSON syntax tree (i.e. a
--   <a>Value</a>) for the <tt>aeson</tt> library
--   
--   NOTE: The <tt>yaml</tt> library uses the same <a>Value</a> type to
--   represent YAML files, so you can use this to convert Dhall expressions
--   to YAML, too
--   
--   See the <tt>dhall</tt> package if you would like to transform Dhall
--   source code into a Dhall syntax tree. Similarly, see the
--   <tt>aeson</tt> package if you would like to translate a JSON syntax
--   tree into JSON.
--   
--   This package also provides <tt>dhall-to-json</tt> and
--   <tt>dhall-to-yaml</tt> executables which you can use to compile Dhall
--   source code directly to JSON or YAML for your convenience
--   
--   Not all Dhall expressions can be converted to JSON since JSON is not a
--   programming language. The only things you can convert are:
--   
--   <ul>
--   <li><tt>Bool</tt>s</li>
--   <li><tt>Natural</tt>s</li>
--   <li><tt>Integer</tt>s</li>
--   <li><tt>Double</tt>s</li>
--   <li><pre>Text</pre></li>
--   <li><tt>List</tt>s</li>
--   <li><tt>Optional</tt> values</li>
--   <li>unions</li>
--   <li>records</li>
--   </ul>
--   
--   Dhall <tt>Bool</tt>s translate to JSON bools:
--   
--   <pre>
--   $ dhall-to-json &lt;&lt;&lt; 'True'
--   true
--   $ dhall-to-json &lt;&lt;&lt; 'False'
--   false
--   </pre>
--   
--   Dhall numbers translate to JSON numbers:
--   
--   <pre>
--   $ dhall-to-json &lt;&lt;&lt; '+2'
--   2
--   $ dhall-to-json &lt;&lt;&lt; '2'
--   2
--   $ dhall-to-json &lt;&lt;&lt; '2.3'
--   2.3
--   </pre>
--   
--   Dhall <tt>Text</tt> translates to JSON text:
--   
--   <pre>
--   $ dhall-to-json &lt;&lt;&lt; '"ABC"'
--   "ABC"
--   </pre>
--   
--   Dhall <tt>List</tt>s translate to JSON lists:
--   
--   <pre>
--   $ dhall-to-json &lt;&lt;&lt; '[1, 2, 3] : List Integer'
--   [1,2,3]
--   </pre>
--   
--   Dhall <tt>Optional</tt> values translate to <tt>null</tt> if absent
--   and the unwrapped value otherwise:
--   
--   <pre>
--   $ dhall-to-json &lt;&lt;&lt; '[] : Optional Integer'
--   null
--   $ dhall-to-json &lt;&lt;&lt; '[1] : Optional Integer'
--   1
--   </pre>
--   
--   Dhall records translate to JSON records:
--   
--   <pre>
--   $ dhall-to-json &lt;&lt;&lt; '{ foo = 1, bar = True }'
--   {"foo":1,"bar":true}
--   </pre>
--   
--   Dhall unions translate to the wrapped value:
--   
--   <pre>
--   $ dhall-to-json &lt;&lt;&lt; "&lt; Left = +2 | Right : Natural&gt;"
--   2
--   $ cat config
--   [ &lt; Person = { age = +47, name = "John" }
--     | Place  : { location : Text }
--     &gt;
--   , &lt; Place  = { location = "North Pole" }
--     | Person : { age : Natural, name : Text }
--     &gt;
--   , &lt; Place  = { location = "Sahara Desert" }
--     | Person : { age : Natural, name : Text }
--     &gt;
--   , &lt; Person = { age = +35, name = "Alice" }
--     | Place  : { location : Text }
--     &gt;
--   ]
--   $ dhall-to-json &lt;&lt;&lt; "./config"
--   [{"age":47,"name":"John"},{"location":"North Pole"},{"location":"Sahara Desert"},{"age":35,"name":"Alice"}]
--   </pre>
--   
--   Also, all Dhall expressions are normalized before translation to JSON:
--   
--   <pre>
--   $ dhall-to-json &lt;&lt;&lt; "True == False"
--   false
--   </pre>
module Dhall.JSON

-- | Convert a Dhall expression to the equivalent JSON expression
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; :set -XOverloadedLists
--   
--   &gt;&gt;&gt; import Dhall.Core
--   
--   &gt;&gt;&gt; dhallToJSON (RecordLit [("foo", IntegerLit 1), ("bar", TextLit "ABC")])
--   Right (Object (fromList [("foo",Number 1.0),("bar",String "ABC")]))
--   
--   &gt;&gt;&gt; fmap Data.Aeson.encode it
--   Right "{\"foo\":1,\"bar\":\"ABC\"}"
--   </pre>
dhallToJSON :: Expr s X -> Either CompileError Value

-- | Omit record fields that are <tt>null</tt>
omitNull :: Value -> Value

-- | Convert a piece of Text carrying a Dhall inscription to an equivalent
--   JSON Value
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; import Dhall.Core
--   
--   &gt;&gt;&gt; Dhall.JSON.codeToValue "(stdin)" "{ a = 1 }"
--   
--   &gt;&gt;&gt; Object (fromList [("a",Number 1.0)])
--   </pre>
codeToValue :: ByteString -> Text -> IO Value

-- | This is the exception type for errors that might arise when
--   translating Dhall to JSON
--   
--   Because the majority of Dhall language features do not translate to
--   JSON this just returns the expression that failed
data CompileError
Unsupported :: (Expr X X) -> CompileError
instance GHC.Show.Show Dhall.JSON.CompileError
instance GHC.Exception.Exception Dhall.JSON.CompileError
