Agda
Safe HaskellNone
LanguageHaskell2010

Agda.Utils.StrictState2

Description

This is a strict state monad, where state update, monadic binding and return are all strict. It is specialized to the case where we have (s, t) for state, i.e. two state components. The reason for specialization is that GHC cannot reliably unbox State (s, t) for any definition of plain State, so we need to directly use unboxed tuples for two state components in the internals.

If you need two strict state components and no other effects, use this module. Do not use Control.Monad.State.Strict for the same purpose; it's not even strict in state updates and is much less amenable to GHC optimizations than this module.

Documentation

newtype State s t a Source #

Constructors

State 

Fields

Instances

Instances details
Applicative (State s t) Source # 
Instance details

Defined in Agda.Utils.StrictState2

Methods

pure :: a -> State s t a #

(<*>) :: State s t (a -> b) -> State s t a -> State s t b #

liftA2 :: (a -> b -> c) -> State s t a -> State s t b -> State s t c #

(*>) :: State s t a -> State s t b -> State s t b #

(<*) :: State s t a -> State s t b -> State s t a #

Functor (State s t) Source # 
Instance details

Defined in Agda.Utils.StrictState2

Methods

fmap :: (a -> b) -> State s t a -> State s t b #

(<$) :: a -> State s t b -> State s t a #

Monad (State s t) Source # 
Instance details

Defined in Agda.Utils.StrictState2

Methods

(>>=) :: State s t a -> (a -> State s t b) -> State s t b #

(>>) :: State s t a -> State s t b -> State s t b #

return :: a -> State s t a #

put :: s -> t -> State s t () Source #

put1 :: s -> State s t () Source #

put2 :: t -> State s t () Source #

get :: State s t (s, t) Source #

get1 :: State s t s Source #

get2 :: State s t t Source #

gets :: ((s, t) -> a) -> State s t a Source #

modify :: ((s, t) -> (s, t)) -> State s t () Source #

modify1 :: (s -> s) -> State s t () Source #

modify2 :: (t -> t) -> State s t () Source #

execState :: State s t a -> (s, t) -> (s, t) Source #

runState :: State s t a -> (s, t) -> (a, (s, t)) Source #

evalState :: State s t a -> (s, t) -> a Source #