Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ReasonOptions = ReasonOptions {}
- data UrlPrefix
- defReasonOptions :: ReasonOptions
- defReasonImports :: Text
- generateReasonForAPI :: (HasForeign LangReason ReasonDatatype api, GenerateList ReasonDatatype (Foreign ReasonDatatype api)) => Proxy api -> [Text]
- generateReasonForAPIWith :: (HasForeign LangReason ReasonDatatype api, GenerateList ReasonDatatype (Foreign ReasonDatatype api)) => ReasonOptions -> Proxy api -> [Text]
- i :: Int
- generateReasonForRequest :: ReasonOptions -> Req ReasonDatatype -> Doc
- mkTypeSignature :: ReasonOptions -> Req ReasonDatatype -> Doc
- reasonHeaderArg :: HeaderArg ReasonDatatype -> Doc
- reasonCaptureArg :: Segment ReasonDatatype -> Doc
- reasonQueryArg :: QueryArg ReasonDatatype -> Doc
- reasonBodyArg :: Doc
- isNotCookie :: HeaderArg f -> Bool
- mkArgs :: ReasonOptions -> Req ReasonDatatype -> Doc
- mkLetParams :: ReasonOptions -> Req ReasonDatatype -> Maybe Doc
- mkRequest :: ReasonOptions -> Req ReasonDatatype -> Doc
- mkUrl :: ReasonOptions -> [Segment ReasonDatatype] -> Doc
- mkQueryParams :: Req ReasonDatatype -> Doc
- isEmptyType :: ReasonOptions -> ReasonDatatype -> Bool
- toStringSrc :: ReasonOptions -> ReasonDatatype -> Doc
- toStringSrcTypes :: ReasonOptions -> ReasonDatatype -> Doc
- isReasonStringType :: ReasonOptions -> ReasonDatatype -> Bool
- isReasonIntType :: ReasonOptions -> ReasonDatatype -> Bool
- isReasonFloatType :: ReasonOptions -> ReasonDatatype -> Bool
- isReasonBoolType :: ReasonOptions -> ReasonDatatype -> Bool
- isReasonCharType :: ReasonOptions -> ReasonDatatype -> Bool
- isReasonMaybeStringType :: ReasonOptions -> ReasonDatatype -> Bool
- isReasonMaybeType :: ReasonDatatype -> Bool
- docToText :: Doc -> Text
- stext :: Text -> Doc
- reasonRecord :: [Doc] -> Doc
- reasonList :: [Doc] -> Doc
- reasonListOfMaybes :: [Doc] -> Doc
Documentation
data ReasonOptions Source #
Options to configure how code is generated.
ReasonOptions | |
|
defReasonOptions :: ReasonOptions Source #
Default options for generating Reason code.
The default options are:
{ urlPrefix = Static "" , reasonExportOptions = Reason.defaultOptions , emptyResponseReasonTypes = [ toReasonType NoContent ] , stringReasonTypes = [ toReasonType "" ] }
defReasonImports :: Text Source #
Default imports required by generated Reason code.
You probably want to include this at the top of your generated Reason module.
generateReasonForAPI :: (HasForeign LangReason ReasonDatatype api, GenerateList ReasonDatatype (Foreign ReasonDatatype api)) => Proxy api -> [Text] Source #
Generate Reason code for the API with default options.
Returns a list of Reason functions to query your Servant API from Reason.
You could spit these out to a file and call them from your Reason code, but you
would be better off creating a Spec
with the result and using specsToDir
,
which handles the module name for you.
generateReasonForAPIWith :: (HasForeign LangReason ReasonDatatype api, GenerateList ReasonDatatype (Foreign ReasonDatatype api)) => ReasonOptions -> Proxy api -> [Text] Source #
Generate Reason code for the API with custom options.
generateReasonForRequest :: ReasonOptions -> Req ReasonDatatype -> Doc Source #
Generate an Reason function for one endpoint.
mkTypeSignature :: ReasonOptions -> Req ReasonDatatype -> Doc Source #
reasonBodyArg :: Doc Source #
isNotCookie :: HeaderArg f -> Bool Source #
mkArgs :: ReasonOptions -> Req ReasonDatatype -> Doc Source #
mkLetParams :: ReasonOptions -> Req ReasonDatatype -> Maybe Doc Source #
mkRequest :: ReasonOptions -> Req ReasonDatatype -> Doc Source #
mkUrl :: ReasonOptions -> [Segment ReasonDatatype] -> Doc Source #
mkQueryParams :: Req ReasonDatatype -> Doc Source #
isEmptyType :: ReasonOptions -> ReasonDatatype -> Bool Source #
Determines whether we construct an Reason function that expects an empty response body.
toStringSrc :: ReasonOptions -> ReasonDatatype -> Doc Source #
Determines how to stringify a value.
toStringSrcTypes :: ReasonOptions -> ReasonDatatype -> Doc Source #
isReasonStringType :: ReasonOptions -> ReasonDatatype -> Bool Source #
Determines whether we call toString
on URL captures and query params of
this type in Reason.
isReasonIntType :: ReasonOptions -> ReasonDatatype -> Bool Source #
Determines whether we call fromInt
on URL captures and query params of this type in Reason.
isReasonFloatType :: ReasonOptions -> ReasonDatatype -> Bool Source #
Determines whether we call fromFloat
on URL captures and query params of
this type in Reason.
isReasonBoolType :: ReasonOptions -> ReasonDatatype -> Bool Source #
Determines whether we convert to true
or false
isReasonCharType :: ReasonOptions -> ReasonDatatype -> Bool Source #
Determines whether we call fromChar
on URL captures and query params of
this type in Reason.
isReasonMaybeStringType :: ReasonOptions -> ReasonDatatype -> Bool Source #
Determines whether a type is 'Maybe a' where a
is something akin to a String
.
reasonRecord :: [Doc] -> Doc Source #
reasonList :: [Doc] -> Doc Source #
reasonListOfMaybes :: [Doc] -> Doc Source #