servant-reason-0.1.2.0: Derive Reason types to interact with a Haskell backend

Safe HaskellNone
LanguageHaskell2010

Servant.Reason.Internal.Generate

Synopsis

Documentation

data ReasonOptions Source #

Options to configure how code is generated.

Constructors

ReasonOptions 

Fields

data UrlPrefix Source #

Constructors

Static Text 
Dynamic 

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.

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.

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.