class (Monad m, HasSource tag s m, HasSink tag s m) => HasState (tag :: k) s (m :: Type -> Type) | tag m -> s whereState capability
An instance should fulfill the following laws. At this point these laws are not definitive, see https://github.com/haskell/mtl/issues/5.
get @t >>= \s1 -> get @t >>= \s2 -> pure (s1, s2) = get @t >>= \s -> pure (s, s)get @t >>= \_ -> put @t s = put @t sput @t s1 >> put @t s2 = put @t s2put @t s >> get @t = put @t s >> pure sstate @t f = get @t >>= \s -> let (a, s') = f s in put @t s' >> pure aMethods
state_ :: Proxy# tag -> (s -> (a, s)) -> m aFor technical reasons, this method needs an extra proxy argument. You only need it if you are defining new instances of 'HasState. Otherwise, you will want to use
state. Seestatefor more documentation.
Instances13HasSource, HasSink, HasState, Reified, …
MonadState s m => HasState tag s (MonadState m)Defined in capability-0.5.0.1 · Capability.State.Internal.Strategies · orphan(HasState tag s m, MonadTrans t, Monad (t m)) => HasState tag s (Lift (t m))Defined in capability-0.5.0.1 · Capability.State.Internal.Strategies · orphanLift one layer in a monad transformer stack.
(MutableRef ref, RefElement ref ~ s, HasReader tag ref m, PrimMonad m, PrimState m ~ MCState ref) => HasState tag s (ReaderRef m)Defined in capability-0.5.0.1 · Capability.State.Internal.Strategies · orphan(HasReader tag (IORef s) m, MonadIO m) => HasState tag s (ReaderIORef m)Defined in capability-0.5.0.1 · Capability.State.Internal.Strategies · orphan(Coercible from to, HasState tag from m, forall x y. Coercible x y => Coercible (m x) (m y)) => HasState tag to (Coerce to m)Defined in capability-0.5.0.1 · Capability.State.Internal.Strategies · orphanConvert the state using safe coercion.
(Monad m, Reifies s' (Reified tag (HasState tag s) m)) => HasSource tag s (Reflected s' (HasState tag s) m)Defined in capability-0.5.0.1 · Capability.State.Internal.ClassHasState oldtag s m => HasState newtag s (Rename oldtag m)Defined in capability-0.5.0.1 · Capability.State.Internal.Strategies · orphanRename the tag.
(forall x. Coercible (m x) (t2 (t1 m) x), Monad m, HasState tag s (t2 (t1 m))) => HasState tag s ((:.:) t2 t1 m)Defined in capability-0.5.0.1 · Capability.State.Internal.Strategies · orphanCompose two accessors.
(Monad m, Reifies s' (Reified tag (HasState tag s) m)) => HasState tag s (Reflected s' (HasState tag s) m)Defined in capability-0.5.0.1 · Capability.State.Internal.Class(Monad m, Reifies s' (Reified tag (HasState tag s) m)) => HasSink tag s (Reflected s' (HasState tag s) m)Defined in capability-0.5.0.1 · Capability.State.Internal.Class(tag ~ field, HasField' field record v, HasState oldtag record m) => HasState tag v (Field field oldtag m)Defined in capability-0.5.0.1 · Capability.State.Internal.Strategies · orphanZoom in on the record field
fieldof typevin the staterecord.(tag ~ pos, HasPosition' pos struct v, HasState oldtag struct m) => HasState tag v (Pos pos oldtag m)Defined in capability-0.5.0.1 · Capability.State.Internal.Strategies · orphanZoom in on the field at position
posof typevin the statestruct.data Reified tag (HasState tag s)ReifiedState_stateSource :: Reified tag (HasSource tag s) m_stateSink :: Reified tag (HasSink tag s) m_state :: forall a. (s -> (a, s)) -> m a