-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Generate PureScript accessor functions for you servant API -- -- Please see README.md @package servant-purescript @version 0.9.0.0 module Servant.PureScript.Internal -- | Our language type is Paramized, so you can choose a custom -- TypeBridge for your translation, by providing your own data -- type and implementing HasBridge for it. -- --
-- data MyBridge -- -- myBridge :: TypeBridge -- myBridge = defaultBridge <|> customBridge1 <|> customBridge2 -- -- instance HasBridge MyBridge where -- languageBridge _ = myBridge --data PureScript bridgeSelector class HasBridge a languageBridge :: HasBridge a => Proxy a -> FullBridge -- | Use PureScript DefaultBridge if defaultBridge -- suffices for your needs. data DefaultBridge -- | languageBridge for DefaultBridge evaluates to -- buildBridge defaultBridge - no surprise there. -- | A proxy for DefaultBridge defaultBridgeProxy :: Proxy DefaultBridge type ParamName = Text data Param f Param :: ParamName -> f -> Param f [_pName] :: Param f -> ParamName [_pType] :: Param f -> f type PSParam = Param PSType pType :: forall f_ad5I f_ahCp. Lens (Param f_ad5I) (Param f_ahCp) f_ad5I f_ahCp pName :: forall f_ad5I. Lens' (Param f_ad5I) ParamName data Settings Settings :: Text -> Set ParamName -> ImportLines -> Bool -> Settings [_apiModuleName] :: Settings -> Text -- | This function parameters should instead be put in a Reader monad. -- -- baseUrl will be put there by default, you can add additional -- parameters. -- -- If your API uses a given parameter name multiple times with different -- types, only the ones matching the type of the first occurrence will be -- put in the Reader monad, all others will still be passed as function -- parameter. [_readerParams] :: Settings -> Set ParamName [_standardImports] :: Settings -> ImportLines -- | If you want codegen for servant-subscriber, set this to True. See the -- central-counter example for a simple usage case. [_generateSubscriberAPI] :: Settings -> Bool standardImports :: Lens' Settings ImportLines readerParams :: Lens' Settings (Set ParamName) generateSubscriberAPI :: Lens' Settings Bool apiModuleName :: Lens' Settings Text defaultSettings :: Settings -- | Add a parameter name to be us put in the Reader monad instead of being -- passed to the generated functions. addReaderParam :: ParamName -> Settings -> Settings baseURLId :: ParamName baseURLParam :: PSParam subscriberToUserId :: ParamName makeTypedToUserParam :: PSType -> PSParam apiToList :: forall bridgeSelector api. (HasForeign (PureScript bridgeSelector) PSType api, GenerateList PSType (Foreign PSType api), HasBridge bridgeSelector) => Proxy api -> Proxy bridgeSelector -> [Req PSType] -- | Transform a given identifer to be a valid PureScript variable name -- (hopefully). toPSVarName :: Text -> Text psTypedToUser :: PSType -> PSType psSubscriptions :: PSType psTypeParameterA :: PSType jsCamelCaseL :: Getter FunctionName Text instance GHC.Show.Show f => GHC.Show.Show (Servant.PureScript.Internal.Param f) instance GHC.Classes.Ord f => GHC.Classes.Ord (Servant.PureScript.Internal.Param f) instance GHC.Classes.Eq f => GHC.Classes.Eq (Servant.PureScript.Internal.Param f) instance (Data.Typeable.Internal.Typeable a, Servant.PureScript.Internal.HasBridge bridgeSelector) => Servant.Foreign.Internal.HasForeignType (Servant.PureScript.Internal.PureScript bridgeSelector) Language.PureScript.Bridge.TypeInfo.PSType a instance Servant.PureScript.Internal.HasBridge Servant.PureScript.Internal.DefaultBridge module Servant.PureScript.CodeGen genModule :: Settings -> [Req PSType] -> Doc genModuleHeader :: Text -> ImportLines -> Doc getReaderParams :: Settings -> [PSParam] -> [PSParam] genParamSettings :: [PSParam] -> Doc genFunction :: [PSParam] -> Req PSType -> Doc genGetReaderParams :: [PSParam] -> Doc genSignature :: Text -> [PSType] -> Maybe PSType -> Doc genSignatureBuilder :: Doc -> Text -> [PSType] -> Maybe PSType -> Doc genFnHead :: Text -> [Text] -> Doc genFnBody :: [PSParam] -> Req PSType -> Doc genBuildURL :: Url PSType -> Doc genBuildPath :: Path PSType -> Doc genBuildSegment :: SegmentType PSType -> Doc genBuildQueryArgs :: [QueryArg PSType] -> Doc genBuildQueryArg :: QueryArg PSType -> Doc genBuildHeaders :: [HeaderArg PSType] -> Doc genBuildHeader :: HeaderArg PSType -> Doc reqsToImportLines :: [Req PSType] -> ImportLines reqToPSTypes :: Req PSType -> [PSType] -- | Extract all function parameters from a given Req. reqToParams :: Req PSType -> [Param PSType] urlToParams :: Url PSType -> [Param PSType] segmentToParam :: SegmentType f -> Maybe (Param f) mkPsMaybe :: PSType -> PSType queryArgToParam :: QueryArg PSType -> Param PSType headerArgToParam :: HeaderArg f -> Param f reqBodyToParam :: Maybe f -> Maybe (Param f) docIntercalate :: Doc -> [Doc] -> Doc textURLEncode :: Bool -> Text -> Text -- | Little helper for generating valid variable names psVar :: Text -> Doc module Servant.PureScript.MakeRequests subscriberImportLines :: Map Text ImportLine genModule :: Settings -> [Req PSType] -> Doc genFunction :: [PSParam] -> Req PSType -> Doc genSignature :: Text -> [PSType] -> Maybe PSType -> Doc genFnBody :: [PSParam] -> Req PSType -> Doc genBuildPath :: Path PSType -> Doc genBuildSegment :: SegmentType PSType -> Doc genBuildQuery :: [QueryArg PSType] -> Doc genBuildQueryArg :: QueryArg PSType -> Doc genBuildHeaders :: [HeaderArg PSType] -> Doc genBuildHeader :: HeaderArg PSType -> Doc psHttpRequest :: PSType module Servant.PureScript.Subscriber genModule :: Settings -> [Req PSType] -> Doc genFunction :: [PSParam] -> Req PSType -> Doc genSignature :: Text -> [PSType] -> Maybe PSType -> Doc genFnBody :: Text -> [Text] -> Doc genFnCall :: Text -> [Text] -> Doc module Servant.PureScript class HasBridge a languageBridge :: HasBridge a => Proxy a -> FullBridge languageBridge :: HasBridge a => Proxy a -> FullBridge -- | Default bridge for mapping primitive/common types: You can append your -- own bridges like this: -- --
-- defaultBridge <|> myBridge1 <|> myBridge2 ---- -- Find examples for bridge definitions in -- Language.PureScript.Bridge.Primitives and -- Language.PureScript.Bridge.Tuple. defaultBridge :: BridgePart -- | A proxy for DefaultBridge defaultBridgeProxy :: Proxy DefaultBridge -- | Use PureScript DefaultBridge if defaultBridge -- suffices for your needs. data DefaultBridge -- | Standard entry point - just create a purescript module with default -- settings for accessing the servant API. writeAPIModule :: forall bridgeSelector api. (HasForeign (PureScript bridgeSelector) PSType api, GenerateList PSType (Foreign PSType api), HasBridge bridgeSelector) => FilePath -> Proxy bridgeSelector -> Proxy api -> IO () writeAPIModuleWithSettings :: forall bridgeSelector api. (HasForeign (PureScript bridgeSelector) PSType api, GenerateList PSType (Foreign PSType api), HasBridge bridgeSelector) => Settings -> FilePath -> Proxy bridgeSelector -> Proxy api -> IO () data Settings Settings :: Text -> Set ParamName -> ImportLines -> Bool -> Settings [_apiModuleName] :: Settings -> Text -- | This function parameters should instead be put in a Reader monad. -- -- baseUrl will be put there by default, you can add additional -- parameters. -- -- If your API uses a given parameter name multiple times with different -- types, only the ones matching the type of the first occurrence will be -- put in the Reader monad, all others will still be passed as function -- parameter. [_readerParams] :: Settings -> Set ParamName [_standardImports] :: Settings -> ImportLines -- | If you want codegen for servant-subscriber, set this to True. See the -- central-counter example for a simple usage case. [_generateSubscriberAPI] :: Settings -> Bool apiModuleName :: Lens' Settings Text readerParams :: Lens' Settings (Set ParamName) standardImports :: Lens' Settings ImportLines defaultSettings :: Settings -- | Add a parameter name to be us put in the Reader monad instead of being -- passed to the generated functions. addReaderParam :: ParamName -> Settings -> Settings -- | Use this function for implementing parseUrlPiece in your -- FromHttpApiData instances in order to be compatible with the generated -- PS code. -- --
-- -- instance ToHttpApiData MyDataType where -- toUrlPiece = jsonToUrlPiece -- toHeader = jsonToHeader -- -- instance FromHttpApiData MyDataType where -- parseUrlPiece = jsonParseUrlPiece -- parseHeader = jsonParseHeader --jsonParseUrlPiece :: FromJSON a => Text -> Either Text a -- | Use this function for implementing toUrlPiece in your -- ToHttpApiData instances in order to be compatible with the generated -- PS code. jsonToUrlPiece :: ToJSON a => a -> Text -- | Use this function for implementing parseHeader in your -- FromHttpApiData instances in order to be compatible with the generated -- PS code. jsonParseHeader :: FromJSON a => ByteString -> Either Text a -- | Use this function for implementing toHeader in your -- ToHttpApiData instances in order to be compatible with the generated -- PS code. jsonToHeader :: ToJSON a => a -> ByteString -- | A header which gets sent by the browser and is thus of no concern for -- the client consumer of the API. module Servant.API.BrowserHeader data BrowserHeader (sym :: Symbol) a instance Servant.Utils.Links.HasLink sub => Servant.Utils.Links.HasLink (Servant.API.BrowserHeader.BrowserHeader sym a Servant.API.Sub.:> sub) instance (GHC.TypeLits.KnownSymbol sym, Web.Internal.HttpApiData.FromHttpApiData a, Servant.Server.Internal.HasServer sublayout context) => Servant.Server.Internal.HasServer (Servant.API.BrowserHeader.BrowserHeader sym a Servant.API.Sub.:> sublayout) context instance (GHC.TypeLits.KnownSymbol sym, Servant.Foreign.Internal.HasForeign lang ftype sublayout) => Servant.Foreign.Internal.HasForeign lang ftype (Servant.API.BrowserHeader.BrowserHeader sym a Servant.API.Sub.:> sublayout)