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


-- | Automatically derive Elm functions to query servant webservices.
--   
--   Please see README.md
@package servant-elm
@version 0.5.0.0

module Servant.Elm.Internal.Foreign
data LangElm
getEndpoints :: (HasForeign LangElm ElmDatatype api, GenerateList ElmDatatype (Foreign ElmDatatype api)) => Proxy api -> [Req ElmDatatype]
instance Elm.Type.ElmType a => Servant.Foreign.Internal.HasForeignType Servant.Elm.Internal.Foreign.LangElm Elm.Type.ElmDatatype a

module Servant.Elm.Internal.Orphans
instance Elm.Type.ElmType Elm.Type.ElmDatatype
instance Elm.Type.ElmType Servant.API.ContentTypes.NoContent
instance Elm.Type.ElmType a => Elm.Type.ElmType (Servant.API.ResponseHeaders.Headers ls a)

module Servant.Elm.Internal.Generate

-- | Options to configure how code is generated.
data ElmOptions
ElmOptions :: UrlPrefix -> Options -> [ElmDatatype] -> [ElmDatatype] -> ElmOptions

-- | The protocol, host and any path prefix to be used as the base for all
--   requests.
--   
--   Example: <tt>Static "<a>https://mydomain.com/api/v1"</a></tt>
--   
--   When <tt>Dynamic</tt>, the generated Elm functions take the base URL
--   as the first argument.
[urlPrefix] :: ElmOptions -> UrlPrefix

-- | Options to pass to elm-export
[elmExportOptions] :: ElmOptions -> Options

-- | Types that represent an empty Http response.
[emptyResponseElmTypes] :: ElmOptions -> [ElmDatatype]

-- | Types that represent a String.
[stringElmTypes] :: ElmOptions -> [ElmDatatype]
data UrlPrefix
Static :: Text -> UrlPrefix
Dynamic :: UrlPrefix

-- | Default options for generating Elm code.
--   
--   The default options are:
--   
--   <pre>
--   { urlPrefix =
--       Static ""
--   , elmExportOptions =
--       Elm.defaultOptions
--   , emptyResponseElmTypes =
--       [ toElmType NoContent ]
--   , stringElmTypes =
--       [ toElmType "" ]
--   }
--   </pre>
defElmOptions :: ElmOptions

-- | Default imports required by generated Elm code.
--   
--   You probably want to include this at the top of your generated Elm
--   module.
--   
--   The default required imports are:
--   
--   <pre>
--   import Json.Decode exposing (..)
--   import Json.Decode.Pipeline exposing (..)
--   import Json.Encode
--   import Http
--   import String
--   </pre>
defElmImports :: Text

-- | Generate Elm code for the API with default options.
--   
--   Returns a list of Elm functions to query your Servant API from Elm.
--   
--   You could spit these out to a file and call them from your Elm code,
--   but you would be better off creating a <tt>Spec</tt> with the result
--   and using <tt>specsToDir</tt>, which handles the module name for you.
generateElmForAPI :: (HasForeign LangElm ElmDatatype api, GenerateList ElmDatatype (Foreign ElmDatatype api)) => Proxy api -> [Text]

-- | Generate Elm code for the API with custom options.
generateElmForAPIWith :: (HasForeign LangElm ElmDatatype api, GenerateList ElmDatatype (Foreign ElmDatatype api)) => ElmOptions -> Proxy api -> [Text]
i :: Int

-- | Generate an Elm function for one endpoint.
generateElmForRequest :: ElmOptions -> Req ElmDatatype -> Doc
mkTypeSignature :: ElmOptions -> Req ElmDatatype -> Doc
elmHeaderArg :: HeaderArg ElmDatatype -> Doc
elmCaptureArg :: Segment ElmDatatype -> Doc
elmQueryArg :: QueryArg ElmDatatype -> Doc
elmBodyArg :: Doc
isNotCookie :: HeaderArg f -> Bool
mkArgs :: ElmOptions -> Req ElmDatatype -> Doc
mkLetParams :: ElmOptions -> Req ElmDatatype -> Maybe Doc
mkRequest :: ElmOptions -> Req ElmDatatype -> Doc
mkUrl :: ElmOptions -> [Segment ElmDatatype] -> Doc
mkQueryParams :: Req ElmDatatype -> Doc

-- | Determines whether we construct an Elm function that expects an empty
--   response body.
isEmptyType :: ElmOptions -> ElmDatatype -> Bool

-- | Determines whether we call <tt>toString</tt> on URL captures and query
--   params of this type in Elm.
isElmStringType :: ElmOptions -> ElmDatatype -> Bool

-- | Determines whether a type is 'Maybe a' where <tt>a</tt> is something
--   akin to a <a>String</a>.
isElmMaybeStringType :: ElmOptions -> ElmDatatype -> Bool
isElmMaybeType :: ElmDatatype -> Bool
docToText :: Doc -> Text
stext :: Text -> Doc
elmRecord :: [Doc] -> Doc
elmList :: [Doc] -> Doc
elmListOfMaybes :: [Doc] -> Doc


-- | Basic usage:
--   
--   <pre>
--   import MyLib (MyServantApiType)
--   import Servant.Elm
--   
--   spec :: Spec
--   spec = Spec ["Generated", "MyApi"]
--               (defElmImports : generateElmForAPI (Proxy :: Proxy MyServantApiType))
--   
--   main :: IO ()
--   main = specsToDir [spec] "my-elm-dir"
--   </pre>
module Servant.Elm

-- | Generate Elm code for the API with default options.
--   
--   Returns a list of Elm functions to query your Servant API from Elm.
--   
--   You could spit these out to a file and call them from your Elm code,
--   but you would be better off creating a <tt>Spec</tt> with the result
--   and using <tt>specsToDir</tt>, which handles the module name for you.
generateElmForAPI :: (HasForeign LangElm ElmDatatype api, GenerateList ElmDatatype (Foreign ElmDatatype api)) => Proxy api -> [Text]

-- | Generate Elm code for the API with custom options.
generateElmForAPIWith :: (HasForeign LangElm ElmDatatype api, GenerateList ElmDatatype (Foreign ElmDatatype api)) => ElmOptions -> Proxy api -> [Text]

-- | Options to configure how code is generated.
data ElmOptions
ElmOptions :: UrlPrefix -> Options -> [ElmDatatype] -> [ElmDatatype] -> ElmOptions

-- | The protocol, host and any path prefix to be used as the base for all
--   requests.
--   
--   Example: <tt>Static "<a>https://mydomain.com/api/v1"</a></tt>
--   
--   When <tt>Dynamic</tt>, the generated Elm functions take the base URL
--   as the first argument.
[urlPrefix] :: ElmOptions -> UrlPrefix

-- | Options to pass to elm-export
[elmExportOptions] :: ElmOptions -> Options

-- | Types that represent an empty Http response.
[emptyResponseElmTypes] :: ElmOptions -> [ElmDatatype]

-- | Types that represent a String.
[stringElmTypes] :: ElmOptions -> [ElmDatatype]
data UrlPrefix
Static :: Text -> UrlPrefix
Dynamic :: UrlPrefix

-- | Default options for generating Elm code.
--   
--   The default options are:
--   
--   <pre>
--   { urlPrefix =
--       Static ""
--   , elmExportOptions =
--       Elm.defaultOptions
--   , emptyResponseElmTypes =
--       [ toElmType NoContent ]
--   , stringElmTypes =
--       [ toElmType "" ]
--   }
--   </pre>
defElmOptions :: ElmOptions

-- | Default imports required by generated Elm code.
--   
--   You probably want to include this at the top of your generated Elm
--   module.
--   
--   The default required imports are:
--   
--   <pre>
--   import Json.Decode exposing (..)
--   import Json.Decode.Pipeline exposing (..)
--   import Json.Encode
--   import Http
--   import String
--   </pre>
defElmImports :: Text
data Spec
Spec :: [Text] -> [Text] -> Spec
class ElmType a
specsToDir :: [Spec] -> FilePath -> IO ()

-- | <a>Proxy</a> is a type that holds no data, but has a phantom parameter
--   of arbitrary type (or even kind). Its use is to provide type
--   information, even though there is no value available of that type (or
--   it may be too costly to create one).
--   
--   Historically, <tt><a>Proxy</a> :: <a>Proxy</a> a</tt> is a safer
--   alternative to the <tt>'undefined :: a'</tt> idiom.
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy (Void, Int -&gt; Int)
--   Proxy
--   </pre>
--   
--   Proxy can even hold types of higher kinds,
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy Either
--   Proxy
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy Functor
--   Proxy
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy complicatedStructure
--   Proxy
--   </pre>
data Proxy (t :: k) :: forall k. () => k -> Type
Proxy :: Proxy
