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


-- | Derive Elm types and Json code from Haskell types, using aeson's options
--   
--   Building the bridge from Haskell to Elm and back. Define types once,
--   and derive the aeson and elm functions at the same time, using any
--   aeson option you like. Cheers!
@package elm-bridge
@version 0.8.4


-- | This module defines how the derived Haskell data types are
--   represented. - It is useful for writing type conversion rules.
module Elm.TyRep

-- | Type definition, including constructors.
data ETypeDef
ETypeAlias :: EAlias -> ETypeDef
ETypePrimAlias :: EPrimAlias -> ETypeDef
ETypeSum :: ESum -> ETypeDef

-- | Type construction : type variables, type constructors, tuples and type
--   application.
data EType
ETyVar :: ETVar -> EType
ETyCon :: ETCon -> EType
ETyApp :: EType -> EType -> EType
ETyTuple :: Int -> EType

-- | Type constructor:
--   
--   <pre>
--   ETCon "Int"
--   </pre>
newtype ETCon
ETCon :: String -> ETCon
[tc_name] :: ETCon -> String

-- | Type variable:
--   
--   <pre>
--   ETVar "a"
--   </pre>
newtype ETVar
ETVar :: String -> ETVar
[tv_name] :: ETVar -> String

-- | Type name:
--   
--   <pre>
--   ETypeName "Map" [ETVar "k", ETVar "v"]
--   </pre>
data ETypeName
ETypeName :: String -> [ETVar] -> ETypeName
[et_name] :: ETypeName -> String
[et_args] :: ETypeName -> [ETVar]
data EPrimAlias
EPrimAlias :: ETypeName -> EType -> EPrimAlias
[epa_name] :: EPrimAlias -> ETypeName
[epa_type] :: EPrimAlias -> EType
data EAlias
EAlias :: ETypeName -> [(String, EType)] -> Bool -> Bool -> Bool -> EAlias
[ea_name] :: EAlias -> ETypeName
[ea_fields] :: EAlias -> [(String, EType)]
[ea_omit_null] :: EAlias -> Bool
[ea_newtype] :: EAlias -> Bool
[ea_unwrap_unary] :: EAlias -> Bool
data SumTypeFields
Anonymous :: [EType] -> SumTypeFields
Named :: [(String, EType)] -> SumTypeFields
isNamed :: SumTypeFields -> Bool
isEmpty :: SumTypeFields -> Bool
data SumTypeConstructor
STC :: String -> String -> SumTypeFields -> SumTypeConstructor
[_stcName] :: SumTypeConstructor -> String
[_stcEncoded] :: SumTypeConstructor -> String
[_stcFields] :: SumTypeConstructor -> SumTypeFields
data ESum
ESum :: ETypeName -> [SumTypeConstructor] -> SumEncoding' -> Bool -> Bool -> ESum
[es_name] :: ESum -> ETypeName
[es_constructors] :: ESum -> [SumTypeConstructor]
[es_type] :: ESum -> SumEncoding'
[es_omit_null] :: ESum -> Bool
[es_unary_strings] :: ESum -> Bool

-- | Transforms tuple types in a list of types. Otherwise returns a
--   singleton list with the original type.
unpackTupleType :: EType -> [EType]
unpackToplevelConstr :: EType -> [EType]
class IsElmDefinition a
compileElmDef :: IsElmDefinition a => Proxy a -> ETypeDef
newtype SumEncoding'
SumEncoding' :: SumEncoding -> SumEncoding'
defSumEncoding :: SumEncoding'

-- | Get an <tt>elm-bridge</tt> type representation for a Haskell type.
--   This can be used to render the type declaration via
--   <a>ElmRenderable</a> or the the JSON serializer/parser names via
--   <a>jsonSerForType</a> and <a>jsonParserForType</a>.
toElmType :: Typeable a => Proxy a -> EType
instance GHC.Classes.Eq Elm.TyRep.EAlias
instance GHC.Classes.Eq Elm.TyRep.EPrimAlias
instance GHC.Classes.Eq Elm.TyRep.ESum
instance GHC.Classes.Eq Elm.TyRep.ETCon
instance GHC.Classes.Eq Elm.TyRep.ETVar
instance GHC.Classes.Eq Elm.TyRep.EType
instance GHC.Classes.Eq Elm.TyRep.ETypeDef
instance GHC.Classes.Eq Elm.TyRep.ETypeName
instance GHC.Classes.Eq Elm.TyRep.SumEncoding'
instance GHC.Classes.Eq Elm.TyRep.SumTypeConstructor
instance GHC.Classes.Eq Elm.TyRep.SumTypeFields
instance GHC.Classes.Ord Elm.TyRep.EAlias
instance GHC.Classes.Ord Elm.TyRep.EPrimAlias
instance GHC.Classes.Ord Elm.TyRep.ESum
instance GHC.Classes.Ord Elm.TyRep.ETCon
instance GHC.Classes.Ord Elm.TyRep.ETVar
instance GHC.Classes.Ord Elm.TyRep.EType
instance GHC.Classes.Ord Elm.TyRep.ETypeName
instance GHC.Classes.Ord Elm.TyRep.SumEncoding'
instance GHC.Classes.Ord Elm.TyRep.SumTypeConstructor
instance GHC.Classes.Ord Elm.TyRep.SumTypeFields
instance GHC.Internal.Show.Show Elm.TyRep.EAlias
instance GHC.Internal.Show.Show Elm.TyRep.EPrimAlias
instance GHC.Internal.Show.Show Elm.TyRep.ESum
instance GHC.Internal.Show.Show Elm.TyRep.ETCon
instance GHC.Internal.Show.Show Elm.TyRep.ETVar
instance GHC.Internal.Show.Show Elm.TyRep.EType
instance GHC.Internal.Show.Show Elm.TyRep.ETypeDef
instance GHC.Internal.Show.Show Elm.TyRep.ETypeName
instance GHC.Internal.Show.Show Elm.TyRep.SumEncoding'
instance GHC.Internal.Show.Show Elm.TyRep.SumTypeConstructor
instance GHC.Internal.Show.Show Elm.TyRep.SumTypeFields


-- | This module should be used to derive the Elm instance alongside the
--   JSON ones. The prefered usage is to convert statements such as :
--   
--   <pre>
--   $(deriveJSON defaultOptions{fieldLabelModifier = drop 4, constructorTagModifier = map toLower} ''D)
--   </pre>
--   
--   into:
--   
--   <pre>
--   $(deriveBoth defaultOptions{fieldLabelModifier = drop 4, constructorTagModifier = map toLower} ''D)
--   </pre>
--   
--   Which will derive both the <tt>aeson</tt> and <tt>elm-bridge</tt>
--   instances at the same time.
module Elm.Derive
data Options
data SumEncoding
TaggedObject :: String -> String -> SumEncoding
[tagFieldName] :: SumEncoding -> String
[contentsFieldName] :: SumEncoding -> String
UntaggedValue :: SumEncoding
ObjectWithSingleField :: SumEncoding
TwoElemArray :: SumEncoding

-- | Note that This default set of options is distinct from that in the
--   <tt>aeson</tt> package.
defaultOptions :: Options

-- | This generates a default set of options. The parameter represents the
--   number of characters that must be dropped from the Haskell field
--   names. The first letter of the field is then converted to lowercase,
--   ie:
--   
--   <pre>
--   data Foo = Foo { _fooBarQux :: Int }
--   $(deriveBoth (defaultOptionsDropLower 4) ''Foo)
--   </pre>
--   
--   Will be encoded as:
--   
--   <pre>
--   {"barQux"=12}
--   </pre>
defaultOptionsDropLower :: Int -> Options

-- | Just derive the <tt>elm-bridge</tt> definitions for generating the
--   serialization/deserialization code. It must be kept synchronized with
--   the Haskell code manually.
deriveElmDef :: Options -> Name -> Q [Dec]

-- | Equivalent to running both <a>deriveJSON</a> and <a>deriveElmDef</a>
--   with the same options, so as to ensure the code on the Haskell and Elm
--   size is synchronized.
deriveBoth :: Options -> Name -> Q [Dec]


-- | This module should not usually be imported.
module Elm.TyRender
class ElmRenderable a
renderElm :: ElmRenderable a => a -> String
instance Elm.TyRender.ElmRenderable Elm.TyRep.EAlias
instance Elm.TyRender.ElmRenderable Elm.TyRep.EPrimAlias
instance Elm.TyRender.ElmRenderable Elm.TyRep.ESum
instance Elm.TyRender.ElmRenderable Elm.TyRep.ETCon
instance Elm.TyRender.ElmRenderable Elm.TyRep.ETVar
instance Elm.TyRender.ElmRenderable Elm.TyRep.EType
instance Elm.TyRender.ElmRenderable Elm.TyRep.ETypeDef
instance Elm.TyRender.ElmRenderable Elm.TyRep.ETypeName


-- | This module implements a generator for JSON serialisers and parsers of
--   arbitrary elm types.
--   
--   It is highly recommended to either only use the functions of
--   <a>Elm.Module</a>, or to use the functions in this module after having
--   modified the <a>ETypeDef</a> arguments with functions such as
--   <tt>defaultAlterations</tt>.
--   
--   The reason is that Elm types might have an equivalent on the Haskell
--   side and should be converted (ie. <tt>Text</tt> -&gt; <a>String</a>,
--   <tt>Vector</tt> -&gt; <a>[]</a>).
module Elm.Json

-- | Compile a JSON parser for an Elm type definition
jsonParserForDef :: ETypeDef -> String

-- | Compile a JSON serializer for an Elm type definition
jsonSerForDef :: ETypeDef -> String

-- | Compile a JSON parser for an Elm type
jsonParserForType :: EType -> String

-- | Compile a JSON serializer for an Elm type.
--   
--   The <tt>omitNothingFields</tt> option is currently not implemented!
jsonSerForType :: EType -> String

-- | Serialize a type like 'type Color = Red | Green | Blue' in a function
--   like
--   
--   <pre>
--   stringEncColor : Color -&gt; String
--   stringEncColor x =
--     case x of
--       Red -&gt; "red"
--       ...
--   </pre>
--   
--   This is mainly useful for types which are used as part of query
--   parameters and url captures.
stringSerForSimpleAdt :: ETypeDef -> String

-- | Parse a String into a maybe-value for simple ADT types. See
--   <a>stringSerForSimpleAdt</a> for motivation
stringParserForSimpleAdt :: ETypeDef -> String
instance GHC.Classes.Eq Elm.Json.MaybeHandling


-- | A type to represent versions of Elm for produced code to work against.
--   
--   This module only supports Elm 0.19.x !!!
module Elm.Versions
data ElmVersion
Elm0p19 :: ElmVersion


-- | Functions in this module are used to generate Elm modules. Note that
--   the generated modules depend on the <tt>bartavelle/json-helpers</tt>
--   package.
module Elm.Module

-- | Existential quantification wrapper for lists of type definitions
data DefineElm
DefineElm :: Proxy a -> DefineElm

-- | The module header line for this version of Elm
moduleHeader :: ElmVersion -> String -> String

-- | Creates an Elm module for the given version. This will use the default
--   type conversion rules (to -- convert <tt>Vector</tt> to <tt>List</tt>,
--   <tt>HashMap a b</tt> to <tt>List (a,b)</tt>, etc.).
makeElmModuleWithVersion :: ElmVersion -> String -> [DefineElm] -> String

-- | Creates an Elm module. This will use the default type conversion rules
--   (to convert <tt>Vector</tt> to <tt>List</tt>, <tt>HashMap a b</tt> to
--   <tt>List (a,b)</tt>, etc.).
--   
--   default to 0.19
makeElmModule :: String -> [DefineElm] -> String

-- | Generates the content of a module. You will be responsible for
--   including the required Elm headers. This uses the default type
--   conversion rules.
makeModuleContent :: [DefineElm] -> String

-- | Generates the content of a module, using custom type conversion rules.
makeModuleContentWithAlterations :: (ETypeDef -> ETypeDef) -> [DefineElm] -> String

-- | A helper function that will recursively traverse type definitions and
--   let you convert types.
--   
--   <pre>
--   myAlteration : ETypeDef -&gt; ETypeDef
--   myAlteration = recAlterType $ \t -&gt; case t of
--                     ETyCon (ETCon "Integer") -&gt; ETyCon (ETCon "Int")
--                     ETyCon (ETCon "Text")    -&gt; ETyCon (ETCon "String")
--                     _                        -&gt; t
--   </pre>
recAlterType :: (EType -> EType) -> ETypeDef -> ETypeDef

-- | Given a list of type names, will <tt>newtype</tt> all the matching
--   type definitions.
newtypeAliases :: [String] -> ETypeDef -> ETypeDef

-- | A default set of type conversion rules:
--   
--   <ul>
--   <li><tt>HashSet a</tt>, <tt>Set a</tt> -&gt; if <tt>a</tt> is
--   comparable, then <tt>Set a</tt>, else <tt>List a</tt></li>
--   <li><tt>HashMap String v</tt>, <tt>Map String v</tt> -&gt; <tt>Dict
--   String v</tt></li>
--   <li><tt>HashMap k v</tt>, <tt>Map k v</tt> -&gt; <tt>List (k,
--   v)</tt></li>
--   <li><tt>Integer</tt> -&gt; <tt>Int</tt></li>
--   <li><tt>Text</tt> -&gt; <tt>String</tt></li>
--   <li><tt>Vector</tt> -&gt; <tt>List</tt></li>
--   <li><tt>Double</tt> -&gt; <tt>Float</tt></li>
--   <li><tt>Tagged t v</tt> -&gt; <tt>v</tt></li>
--   </ul>
defaultAlterations :: ETypeDef -> ETypeDef
defaultTypeAlterations :: EType -> EType
