Skip to content

Commit

Permalink
Add mapStoreT (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashoneyman authored Dec 3, 2021
1 parent e37224d commit 368a8e4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Halogen/Store/Monad.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Halogen.Store.Monad where
import Prelude

import Control.Monad.Error.Class (class MonadError, class MonadThrow)
import Control.Monad.Reader (class MonadAsk, ReaderT, ask, lift, runReaderT)
import Control.Monad.Reader (class MonadAsk, ReaderT, ask, lift, mapReaderT, runReaderT)
import Data.Foldable (traverse_)
import Data.Maybe (Maybe(..))
import Effect (Effect)
Expand Down Expand Up @@ -137,3 +137,7 @@ runStoreT initialStore reducer component = do
{ emitter, listener } <- HS.create
pure { value, emitter, listener, reducer }
pure $ hoist (\(StoreT m) -> runReaderT m hs) component

-- | Change the type of the result in a `StoreT` monad.
mapStoreT :: forall a s m1 m2 b c. (m1 b -> m2 c) -> StoreT a s m1 b -> StoreT a s m2 c
mapStoreT f (StoreT m) = StoreT (mapReaderT f m)

0 comments on commit 368a8e4

Please sign in to comment.