planet-mitchell-0.1.0: Planet Mitchell

Safe HaskellSafe
LanguageHaskell2010

Reader

Contents

Synopsis

Reader

type Reader r = ReaderT r Identity #

The parameterizable reader monad.

Computations are functions of a shared environment.

The return function ignores the environment, while >>= passes the inherited environment to both subcomputations.

runReader #

Arguments

:: Reader r a

A Reader to run.

-> r

An initial environment.

-> a 

Runs a Reader and extracts the final value from it. (The inverse of reader.)

mapReader :: (a -> b) -> Reader r a -> Reader r b #

Transform the value returned by a Reader.

withReader #

Arguments

:: (r' -> r)

The function to modify the environment.

-> Reader r a

Computation to run in the modified environment.

-> Reader r' a 

Execute a computation in a modified environment (a specialization of withReaderT).

ReaderT

newtype ReaderT r (m :: k -> *) (a :: k) :: forall k. * -> (k -> *) -> k -> * #

The reader monad transformer, which adds a read-only environment to the given monad.

The return function ignores the environment, while >>= passes the inherited environment to both subcomputations.

Constructors

ReaderT 

Fields

Instances
MonadParsec e s m => MonadParsec e s (ReaderT r m) 
Instance details

Defined in Text.Megaparsec.Class

Methods

failure :: Maybe (ErrorItem (Token s)) -> Set (ErrorItem (Token s)) -> ReaderT r m a #

fancyFailure :: Set (ErrorFancy e) -> ReaderT r m a #

label :: String -> ReaderT r m a -> ReaderT r m a #

hidden :: ReaderT r m a -> ReaderT r m a #

try :: ReaderT r m a -> ReaderT r m a #

lookAhead :: ReaderT r m a -> ReaderT r m a #

notFollowedBy :: ReaderT r m a -> ReaderT r m () #

withRecovery :: (ParseError (Token s) e -> ReaderT r m a) -> ReaderT r m a -> ReaderT r m a #

observing :: ReaderT r m a -> ReaderT r m (Either (ParseError (Token s) e) a) #

eof :: ReaderT r m () #

token :: (Token s -> Either (Maybe (ErrorItem (Token s)), Set (ErrorItem (Token s))) a) -> Maybe (Token s) -> ReaderT r m a #

tokens :: (Tokens s -> Tokens s -> Bool) -> Tokens s -> ReaderT r m (Tokens s) #

takeWhileP :: Maybe String -> (Token s -> Bool) -> ReaderT r m (Tokens s) #

takeWhile1P :: Maybe String -> (Token s -> Bool) -> ReaderT r m (Tokens s) #

takeP :: Maybe String -> Int -> ReaderT r m (Tokens s) #

getParserState :: ReaderT r m (State s) #

updateParserState :: (State s -> State s) -> ReaderT r m () #

Monad m => MonadReader r (ReaderT r m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ReaderT r m r #

local :: (r -> r) -> ReaderT r m a -> ReaderT r m a #

reader :: (r -> a) -> ReaderT r m a #

MonadState s m => MonadState s (ReaderT r m) 
Instance details

Defined in Control.Monad.State.Class

Methods

get :: ReaderT r m s #

put :: s -> ReaderT r m () #

state :: (s -> (a, s)) -> ReaderT r m a #

(Functor f, MonadFree f m) => MonadFree f (ReaderT e m) 
Instance details

Defined in Control.Monad.Free.Class

Methods

wrap :: f (ReaderT e m a) -> ReaderT e m a #

MonadError e m => MonadError e (ReaderT r m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> ReaderT r m a #

catchError :: ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a #

MonadWriter w m => MonadWriter w (ReaderT r m) 
Instance details

Defined in Control.Monad.Writer.Class

Methods

writer :: (a, w) -> ReaderT r m a #

tell :: w -> ReaderT r m () #

listen :: ReaderT r m a -> ReaderT r m (a, w) #

pass :: ReaderT r m (a, w -> w) -> ReaderT r m a #

MonadBase b m => MonadBase b (ReaderT r m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> ReaderT r m α #

MFunctor (ReaderT r :: (* -> *) -> * -> *) 
Instance details

Defined in Control.Monad.Morph

Methods

hoist :: Monad m => (forall a. m a -> n a) -> ReaderT r m b -> ReaderT r n b #

MonadTrans (ReaderT r :: (* -> *) -> * -> *) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

lift :: Monad m => m a -> ReaderT r m a #

MMonad (ReaderT r :: (* -> *) -> * -> *) 
Instance details

Defined in Control.Monad.Morph

Methods

embed :: Monad n => (forall a. m a -> ReaderT r n a) -> ReaderT r m b -> ReaderT r n b #

Monad m => Monad (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

(>>=) :: ReaderT r m a -> (a -> ReaderT r m b) -> ReaderT r m b #

(>>) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m b #

return :: a -> ReaderT r m a #

fail :: String -> ReaderT r m a #

Functor m => Functor (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

fmap :: (a -> b) -> ReaderT r m a -> ReaderT r m b #

(<$) :: a -> ReaderT r m b -> ReaderT r m a #

MonadFix m => MonadFix (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

mfix :: (a -> ReaderT r m a) -> ReaderT r m a #

MonadFail m => MonadFail (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

fail :: String -> ReaderT r m a #

Applicative m => Applicative (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

pure :: a -> ReaderT r m a #

(<*>) :: ReaderT r m (a -> b) -> ReaderT r m a -> ReaderT r m b #

liftA2 :: (a -> b -> c) -> ReaderT r m a -> ReaderT r m b -> ReaderT r m c #

(*>) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m b #

(<*) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m a #

Alternative m => Alternative (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

empty :: ReaderT r m a #

(<|>) :: ReaderT r m a -> ReaderT r m a -> ReaderT r m a #

some :: ReaderT r m a -> ReaderT r m [a] #

many :: ReaderT r m a -> ReaderT r m [a] #

Distributive g => Distributive (ReaderT e g) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (ReaderT e g a) -> ReaderT e g (f a) #

collect :: Functor f => (a -> ReaderT e g b) -> f a -> ReaderT e g (f b) #

distributeM :: Monad m => m (ReaderT e g a) -> ReaderT e g (m a) #

collectM :: Monad m => (a -> ReaderT e g b) -> m a -> ReaderT e g (m b) #

Contravariant m => Contravariant (ReaderT r m) 
Instance details

Defined in Data.Functor.Contravariant

Methods

contramap :: (a -> b) -> ReaderT r m b -> ReaderT r m a #

(>$) :: b -> ReaderT r m b -> ReaderT r m a #

Representable m => Representable (ReaderT e m) 
Instance details

Defined in Data.Functor.Rep

Associated Types

type Rep (ReaderT e m) :: * #

Methods

tabulate :: (Rep (ReaderT e m) -> a) -> ReaderT e m a #

index :: ReaderT e m a -> Rep (ReaderT e m) -> a #

MonadPlus m => MonadPlus (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

mzero :: ReaderT r m a #

mplus :: ReaderT r m a -> ReaderT r m a -> ReaderT r m a #

MonadZip m => MonadZip (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

mzip :: ReaderT r m a -> ReaderT r m b -> ReaderT r m (a, b) #

mzipWith :: (a -> b -> c) -> ReaderT r m a -> ReaderT r m b -> ReaderT r m c #

munzip :: ReaderT r m (a, b) -> (ReaderT r m a, ReaderT r m b) #

MonadIO m => MonadIO (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

liftIO :: IO a -> ReaderT r m a #

Divisible m => Divisible (ReaderT r m) 
Instance details

Defined in Data.Functor.Contravariant.Divisible

Methods

divide :: (a -> (b, c)) -> ReaderT r m b -> ReaderT r m c -> ReaderT r m a #

conquer :: ReaderT r m a #

Decidable m => Decidable (ReaderT r m) 
Instance details

Defined in Data.Functor.Contravariant.Divisible

Methods

lose :: (a -> Void) -> ReaderT r m a #

choose :: (a -> Either b c) -> ReaderT r m b -> ReaderT r m c -> ReaderT r m a #

MonadThrow m => MonadThrow (ReaderT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> ReaderT r m a #

MonadCatch m => MonadCatch (ReaderT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a #

MonadMask m => MonadMask (ReaderT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. ReaderT r m a -> ReaderT r m a) -> ReaderT r m b) -> ReaderT r m b #

uninterruptibleMask :: ((forall a. ReaderT r m a -> ReaderT r m a) -> ReaderT r m b) -> ReaderT r m b #

generalBracket :: ReaderT r m a -> (a -> ExitCase b -> ReaderT r m c) -> (a -> ReaderT r m b) -> ReaderT r m (b, c) #

PrimMonad m => PrimMonad (ReaderT r m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (ReaderT r m) :: * #

Methods

primitive :: (State# (PrimState (ReaderT r m)) -> (#State# (PrimState (ReaderT r m)), a#)) -> ReaderT r m a #

Apply m => Apply (ReaderT e m) 
Instance details

Defined in Data.Functor.Bind.Class

Methods

(<.>) :: ReaderT e m (a -> b) -> ReaderT e m a -> ReaderT e m b #

(.>) :: ReaderT e m a -> ReaderT e m b -> ReaderT e m b #

(<.) :: ReaderT e m a -> ReaderT e m b -> ReaderT e m a #

liftF2 :: (a -> b -> c) -> ReaderT e m a -> ReaderT e m b -> ReaderT e m c #

MonadLogic m => MonadLogic (ReaderT e m) 
Instance details

Defined in Control.Monad.Logic.Class

Methods

msplit :: ReaderT e m a -> ReaderT e m (Maybe (a, ReaderT e m a)) #

interleave :: ReaderT e m a -> ReaderT e m a -> ReaderT e m a #

(>>-) :: ReaderT e m a -> (a -> ReaderT e m b) -> ReaderT e m b #

ifte :: ReaderT e m a -> (a -> ReaderT e m b) -> ReaderT e m b -> ReaderT e m b #

once :: ReaderT e m a -> ReaderT e m a #

MonadManaged m => MonadManaged (ReaderT r m) 
Instance details

Defined in Control.Monad.Managed

Methods

using :: Managed a -> ReaderT r m a #

MonadCont m => MonadCont (ReaderT r m) 
Instance details

Defined in Control.Monad.Cont.Class

Methods

callCC :: ((a -> ReaderT r m b) -> ReaderT r m a) -> ReaderT r m a #

Pointed m => Pointed (ReaderT r m) 
Instance details

Defined in Data.Pointed

Methods

point :: a -> ReaderT r m a #

Plus f => Plus (ReaderT e f) 
Instance details

Defined in Data.Functor.Plus

Methods

zero :: ReaderT e f a #

Alt f => Alt (ReaderT e f) 
Instance details

Defined in Data.Functor.Alt

Methods

(<!>) :: ReaderT e f a -> ReaderT e f a -> ReaderT e f a #

some :: Applicative (ReaderT e f) => ReaderT e f a -> ReaderT e f [a] #

many :: Applicative (ReaderT e f) => ReaderT e f a -> ReaderT e f [a] #

Bind m => Bind (ReaderT e m) 
Instance details

Defined in Data.Functor.Bind.Class

Methods

(>>-) :: ReaderT e m a -> (a -> ReaderT e m b) -> ReaderT e m b #

join :: ReaderT e m (ReaderT e m a) -> ReaderT e m a #

MonadUnliftIO m => MonadUnliftIO (ReaderT r m) 
Instance details

Defined in Control.Monad.IO.Unlift

Methods

askUnliftIO :: ReaderT r m (UnliftIO (ReaderT r m)) #

withRunInIO :: ((forall a. ReaderT r m a -> IO a) -> IO b) -> ReaderT r m b #

Zoom m n s t => Zoom (ReaderT e m) (ReaderT e n) s t 
Instance details

Defined in Control.Lens.Zoom

Methods

zoom :: LensLike' (Zoomed (ReaderT e m) c) t s -> ReaderT e m c -> ReaderT e n c #

Monad m => Magnify (ReaderT b m) (ReaderT a m) b a 
Instance details

Defined in Control.Lens.Zoom

Methods

magnify :: LensLike' (Magnified (ReaderT b m) c) a b -> ReaderT b m c -> ReaderT a m c #

Wrapped (ReaderT r m a) 
Instance details

Defined in Control.Lens.Wrapped

Associated Types

type Unwrapped (ReaderT r m a) :: * #

Methods

_Wrapped' :: Iso' (ReaderT r m a) (Unwrapped (ReaderT r m a)) #

t ~ ReaderT s n b => Rewrapped (ReaderT r m a) t 
Instance details

Defined in Control.Lens.Wrapped

type Rep (ReaderT e m) 
Instance details

Defined in Data.Functor.Rep

type Rep (ReaderT e m) = (e, Rep m)
type Zoomed (ReaderT e m) 
Instance details

Defined in Control.Lens.Zoom

type Zoomed (ReaderT e m) = Zoomed m
type Magnified (ReaderT b m) 
Instance details

Defined in Control.Lens.Zoom

type Magnified (ReaderT b m) = Effect m
type PrimState (ReaderT r m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (ReaderT r m) = PrimState m
type Unwrapped (ReaderT r m a) 
Instance details

Defined in Control.Lens.Wrapped

type Unwrapped (ReaderT r m a) = r -> m a

mapReaderT :: (m a -> n b) -> ReaderT r m a -> ReaderT r n b #

Transform the computation inside a ReaderT.

withReaderT #

Arguments

:: (r' -> r)

The function to modify the environment.

-> ReaderT r m a

Computation to run in the modified environment.

-> ReaderT r' m a 

Execute a computation in a modified environment (a more general version of local).

MonadReader

class Monad m => MonadReader r (m :: * -> *) | m -> r where #

See examples in Control.Monad.Reader. Note, the partially applied function type (->) r is a simple reader monad. See the instance declaration below.

Minimal complete definition

(ask | reader), local

Methods

ask :: m r #

Retrieves the monad environment.

local #

Arguments

:: (r -> r)

The function to modify the environment.

-> m a

Reader to run in the modified environment.

-> m a 

Executes a computation in a modified environment.

reader #

Arguments

:: (r -> a)

The selector function to apply to the environment.

-> m a 

Retrieves a function of the current environment.

Instances
MonadReader r m => MonadReader r (MaybeT m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: MaybeT m r #

local :: (r -> r) -> MaybeT m a -> MaybeT m a #

reader :: (r -> a) -> MaybeT m a #

MonadReader r m => MonadReader r (ListT m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ListT m r #

local :: (r -> r) -> ListT m a -> ListT m a #

reader :: (r -> a) -> ListT m a #

MonadReader r m => MonadReader r (LogicT m) 
Instance details

Defined in Control.Monad.Logic

Methods

ask :: LogicT m r #

local :: (r -> r) -> LogicT m a -> LogicT m a #

reader :: (r -> a) -> LogicT m a #

MonadReader i m => MonadReader i (ListT m) 
Instance details

Defined in List.Transformer

Methods

ask :: ListT m i #

local :: (i -> i) -> ListT m a -> ListT m a #

reader :: (i -> a) -> ListT m a #

MonadReader s (ReifiedGetter s) 
Instance details

Defined in Control.Lens.Reified

Methods

ask :: ReifiedGetter s s #

local :: (s -> s) -> ReifiedGetter s a -> ReifiedGetter s a #

reader :: (s -> a) -> ReifiedGetter s a #

MonadReader s (ReifiedFold s) 
Instance details

Defined in Control.Lens.Reified

Methods

ask :: ReifiedFold s s #

local :: (s -> s) -> ReifiedFold s a -> ReifiedFold s a #

reader :: (s -> a) -> ReifiedFold s a #

(Functor m, MonadReader e m) => MonadReader e (Free m) 
Instance details

Defined in Control.Monad.Free

Methods

ask :: Free m e #

local :: (e -> e) -> Free m a -> Free m a #

reader :: (e -> a) -> Free m a #

(Representable f, Rep f ~ a) => MonadReader a (Co f) 
Instance details

Defined in Data.Functor.Rep

Methods

ask :: Co f a #

local :: (a -> a) -> Co f a0 -> Co f a0 #

reader :: (a -> a0) -> Co f a0 #

(Monoid w, MonadReader r m) => MonadReader r (WriterT w m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: WriterT w m r #

local :: (r -> r) -> WriterT w m a -> WriterT w m a #

reader :: (r -> a) -> WriterT w m a #

(Monoid w, MonadReader r m) => MonadReader r (WriterT w m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: WriterT w m r #

local :: (r -> r) -> WriterT w m a -> WriterT w m a #

reader :: (r -> a) -> WriterT w m a #

MonadReader r m => MonadReader r (StateT s m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: StateT s m r #

local :: (r -> r) -> StateT s m a -> StateT s m a #

reader :: (r -> a) -> StateT s m a #

MonadReader r m => MonadReader r (StateT s m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: StateT s m r #

local :: (r -> r) -> StateT s m a -> StateT s m a #

reader :: (r -> a) -> StateT s m a #

MonadReader r m => MonadReader r (IdentityT m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: IdentityT m r #

local :: (r -> r) -> IdentityT m a -> IdentityT m a #

reader :: (r -> a) -> IdentityT m a #

MonadReader r m => MonadReader r (ExceptT e m)

Since: mtl-2.2

Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ExceptT e m r #

local :: (r -> r) -> ExceptT e m a -> ExceptT e m a #

reader :: (r -> a) -> ExceptT e m a #

(Error e, MonadReader r m) => MonadReader r (ErrorT e m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ErrorT e m r #

local :: (r -> r) -> ErrorT e m a -> ErrorT e m a #

reader :: (r -> a) -> ErrorT e m a #

(Functor f, MonadReader r m) => MonadReader r (FreeT f m) 
Instance details

Defined in Control.Monad.Trans.Free

Methods

ask :: FreeT f m r #

local :: (r -> r) -> FreeT f m a -> FreeT f m a #

reader :: (r -> a) -> FreeT f m a #

(Stream s, MonadReader r m) => MonadReader r (ParsecT e s m) 
Instance details

Defined in Text.Megaparsec.Internal

Methods

ask :: ParsecT e s m r #

local :: (r -> r) -> ParsecT e s m a -> ParsecT e s m a #

reader :: (r -> a) -> ParsecT e s m a #

Monad m => MonadReader r (ReaderT r m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ReaderT r m r #

local :: (r -> r) -> ReaderT r m a -> ReaderT r m a #

reader :: (r -> a) -> ReaderT r m a #

MonadReader r ((->) r :: * -> *) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: r -> r #

local :: (r -> r) -> (r -> a) -> r -> a #

reader :: (r -> a) -> r -> a #

MonadReader r' m => MonadReader r' (ContT r m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ContT r m r' #

local :: (r' -> r') -> ContT r m a -> ContT r m a #

reader :: (r' -> a) -> ContT r m a #

(Monad m, Monoid w) => MonadReader r (RWST r w s m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: RWST r w s m r #

local :: (r -> r) -> RWST r w s m a -> RWST r w s m a #

reader :: (r -> a) -> RWST r w s m a #

(Monad m, Monoid w) => MonadReader r (RWST r w s m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: RWST r w s m r #

local :: (r -> r) -> RWST r w s m a -> RWST r w s m a #

reader :: (r -> a) -> RWST r w s m a #

Magnify

class (Magnified m ~ Magnified n, MonadReader b m, MonadReader a n) => Magnify (m :: * -> *) (n :: * -> *) b a | m -> b, n -> a, m a -> n, n b -> m #

This class allows us to use magnify part of the environment, changing the environment supplied by many different Monad transformers. Unlike zoom this can change the environment of a deeply nested Monad transformer.

Also, unlike zoom, this can be used with any valid Getter, but cannot be used with a Traversal or Fold.

Minimal complete definition

magnify

Instances
Magnify m n b a => Magnify (IdentityT m) (IdentityT n) b a 
Instance details

Defined in Control.Lens.Zoom

Methods

magnify :: LensLike' (Magnified (IdentityT m) c) a b -> IdentityT m c -> IdentityT n c #

Magnify ((->) b :: * -> *) ((->) a :: * -> *) b a
magnify = views
Instance details

Defined in Control.Lens.Zoom

Methods

magnify :: LensLike' (Magnified ((->) b) c) a b -> (b -> c) -> a -> c #

Monad m => Magnify (ReaderT b m) (ReaderT a m) b a 
Instance details

Defined in Control.Lens.Zoom

Methods

magnify :: LensLike' (Magnified (ReaderT b m) c) a b -> ReaderT b m c -> ReaderT a m c #

(Monad m, Monoid w) => Magnify (RWST b w s m) (RWST a w s m) b a 
Instance details

Defined in Control.Lens.Zoom

Methods

magnify :: LensLike' (Magnified (RWST b w s m) c) a b -> RWST b w s m c -> RWST a w s m c #

(Monad m, Monoid w) => Magnify (RWST b w s m) (RWST a w s m) b a 
Instance details

Defined in Control.Lens.Zoom

Methods

magnify :: LensLike' (Magnified (RWST b w s m) c) a b -> RWST b w s m c -> RWST a w s m c #

magnify :: Magnify m n b a => LensLike' (Magnified m c) a b -> m c -> n c infixr 2 #

Run a monadic action in a larger environment than it was defined in, using a Getter.

This acts like local, but can in many cases change the type of the environment as well.

This is commonly used to lift actions in a simpler Reader Monad into a Monad with a larger environment type.

This can be used to edit pretty much any Monad transformer stack with an environment in it:

>>> (1,2) & magnify _2 (+1)
3
>>> flip Reader.runReader (1,2) $ magnify _1 Reader.ask
1
>>> flip Reader.runReader (1,2,[10..20]) $ magnify (_3._tail) Reader.ask
[11,12,13,14,15,16,17,18,19,20]
magnify :: Getter s a -> (a -> r) -> s -> r
magnify :: Monoid r => Fold s a   -> (a -> r) -> s -> r
magnify :: Monoid w                 => Getter s t -> RWS t w st c -> RWS s w st c
magnify :: (Monoid w, Monoid c) => Fold s a   -> RWS a w st c -> RWS s w st c
...