Module
Redox.Utils
- Package
- purescript-redox
- Repository
- coot/purescript-redox
#hoistCofree' Source
hoistCofree' :: forall state f. Functor f => (f (Cofree f state) -> f (Cofree f state)) -> Cofree f state -> Cofree f state
A version of hoistCofree
, where nat
does not need to come from natural
transformation.
This corresponds to
applyMiddleware
in the redux library.
You can use this function to add effects to your interpreter, like
logging, optimistic updates, undo/redo stack, delayed actions...
For example a simple logger:
addLogger
:: forall state f
. (Functor f)
=> Cofree f state
-> Cofree f state
addLogger interp = hoistCofree' nat interp
where
nat :: f (Cofree f state) -> f (Cofree f state)
nat fa = g <$> fa
g :: Cofree f state -> Cofree f state
g cof = unsafePerformEff do
-- Control.Comonad.Cofree.head
log $ unsafeCoerce (head cof)
pure cof
- Modules
- Redox
- Redox.
DSL - Redox.
Store - Redox.
Utils