Safe Haskell | None |
---|---|
Language | GHC2021 |
Synopsis
- session :: forall a (es :: [Effect]). (Session a, DefaultParam a, FromParam a, Hyperbole :> es) => Eff es a
- lookupSession :: forall a (es :: [Effect]). (Session a, FromParam a, Hyperbole :> es) => Eff es (Maybe a)
- saveSession :: forall a (es :: [Effect]). (Session a, ToParam a, Hyperbole :> es) => a -> Eff es ()
- modifySession :: forall a (es :: [Effect]). (Session a, DefaultParam a, ToParam a, FromParam a, Hyperbole :> es) => (a -> a) -> Eff es a
- modifySession_ :: forall a (es :: [Effect]). (Session a, DefaultParam a, ToParam a, FromParam a, Hyperbole :> es) => (a -> a) -> Eff es ()
- deleteSession :: forall a (es :: [Effect]). (Session a, Hyperbole :> es) => Eff es ()
- parseSession :: forall a (es :: [Effect]). (FromParam a, Hyperbole :> es) => Param -> ParamValue -> Eff es a
- setCookie :: forall a (es :: [Effect]). (ToParam a, Hyperbole :> es) => Cookie -> Eff es ()
- modifyCookies :: forall (es :: [Effect]). Hyperbole :> es => (Cookies -> Cookies) -> Eff es ()
- sessionCookies :: forall (es :: [Effect]). Hyperbole :> es => Eff es Cookies
- clientSessionCookies :: forall (es :: [Effect]). Hyperbole :> es => Eff es Cookies
- requestSessionCookies :: forall (es :: [Effect]). Hyperbole :> es => Eff es Cookies
Documentation
session :: forall a (es :: [Effect]). (Session a, DefaultParam a, FromParam a, Hyperbole :> es) => Eff es a Source #
Persist datatypes in browser cookies. If the session doesn't exist, the DefaultParam
is used
data Preferences = Preferences { color :: AppColor } deriving (Generic, Show, Read,ToParam
,FromParam
,Session
) instanceDefaultParam
Preferences where defaultParam = Preferences White page :: (Hyperbole
:> es) =>Eff
es (Page
'[Content]) page = do prefs <- session @Preferences pure $el
(bg prefs.color) "Custom Background"
lookupSession :: forall a (es :: [Effect]). (Session a, FromParam a, Hyperbole :> es) => Eff es (Maybe a) Source #
Return a session if it exists
saveSession :: forall a (es :: [Effect]). (Session a, ToParam a, Hyperbole :> es) => a -> Eff es () Source #
Persist datatypes in browser cookies
data Preferences = Preferences { color :: AppColor } deriving (Generic, Show, Read,ToParam
,FromParam
,Session
) instanceDefaultParam
Preferences where defaultParam = Preferences White instanceHyperView
Content es where dataAction
Content = SetColor AppColor deriving (Show, Read,ViewAction
)update
(SetColor clr) = do let prefs = Preferences clr saveSession prefs pure $el
(bg prefs.color) "Custom Background"
modifySession :: forall a (es :: [Effect]). (Session a, DefaultParam a, ToParam a, FromParam a, Hyperbole :> es) => (a -> a) -> Eff es a Source #
modifySession_ :: forall a (es :: [Effect]). (Session a, DefaultParam a, ToParam a, FromParam a, Hyperbole :> es) => (a -> a) -> Eff es () Source #
deleteSession :: forall a (es :: [Effect]). (Session a, Hyperbole :> es) => Eff es () Source #
Remove a single Session
from the browser cookies
parseSession :: forall a (es :: [Effect]). (FromParam a, Hyperbole :> es) => Param -> ParamValue -> Eff es a Source #
setCookie :: forall a (es :: [Effect]). (ToParam a, Hyperbole :> es) => Cookie -> Eff es () Source #
save a single datatype to a specific key in the session
modifyCookies :: forall (es :: [Effect]). Hyperbole :> es => (Cookies -> Cookies) -> Eff es () Source #
Modify the client cookies
sessionCookies :: forall (es :: [Effect]). Hyperbole :> es => Eff es Cookies Source #
Return all the cookies, both those sent in the request and others added by the page