Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ElmOptions = ElmOptions {
- urlPrefix :: Text
- elmExportOptions :: Options
- emptyResponseElmTypes :: [ElmDatatype]
- stringElmTypes :: [ElmDatatype]
- defElmOptions :: ElmOptions
- defElmImports :: Text
- generateElmForAPI :: (HasForeign LangElm ElmDatatype api, GenerateList ElmDatatype (Foreign ElmDatatype api)) => Proxy api -> [Text]
- generateElmForAPIWith :: (HasForeign LangElm ElmDatatype api, GenerateList ElmDatatype (Foreign ElmDatatype api)) => ElmOptions -> Proxy api -> [Text]
- i :: Int
- generateElmForRequest :: ElmOptions -> Req ElmDatatype -> Doc
- mkTypeSignature :: ElmOptions -> Req ElmDatatype -> Doc
- mkArgs :: Req ElmDatatype -> Doc
- mkLetParams :: ElmOptions -> Req ElmDatatype -> Maybe Doc
- mkRequest :: ElmOptions -> Req ElmDatatype -> Doc
- mkUrl :: ElmOptions -> [Segment ElmDatatype] -> Doc
- mkQueryParams :: Req ElmDatatype -> Doc
- isEmptyType :: ElmOptions -> ElmDatatype -> Bool
- isElmStringType :: ElmOptions -> ElmDatatype -> Bool
- docToText :: Doc -> Text
- stext :: Text -> Doc
- elmRecord :: [Doc] -> Doc
- elmList :: [Doc] -> Doc
Documentation
data ElmOptions Source #
Options to configure how code is generated.
ElmOptions | |
|
defElmOptions :: ElmOptions Source #
Default options for generating Elm code.
The default options are:
{ urlPrefix = "" , elmExportOptions = Elm.defaultOptions , emptyResponseElmTypes = [ toElmType NoContent ] , stringElmTypes = [ toElmType "" ] }
defElmImports :: Text Source #
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:
import Json.Decode exposing (..) import Json.Decode.Pipeline exposing (..) import Json.Encode import Http import String
generateElmForAPI :: (HasForeign LangElm ElmDatatype api, GenerateList ElmDatatype (Foreign ElmDatatype api)) => Proxy api -> [Text] Source #
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 Spec
with the result and using specsToDir
,
which handles the module name for you.
generateElmForAPIWith :: (HasForeign LangElm ElmDatatype api, GenerateList ElmDatatype (Foreign ElmDatatype api)) => ElmOptions -> Proxy api -> [Text] Source #
Generate Elm code for the API with custom options.
generateElmForRequest :: ElmOptions -> Req ElmDatatype -> Doc Source #
Generate an Elm function for one endpoint.
mkTypeSignature :: ElmOptions -> Req ElmDatatype -> Doc Source #
mkLetParams :: ElmOptions -> Req ElmDatatype -> Maybe Doc Source #
mkQueryParams :: Req ElmDatatype -> Doc Source #
isEmptyType :: ElmOptions -> ElmDatatype -> Bool Source #
Determines whether we construct an Elm function that expects an empty response body.
isElmStringType :: ElmOptions -> ElmDatatype -> Bool Source #
Determines whether we call toString
on URL captures and query params of
this type in Elm.