GHC.Utils.Monad.State.Lazy

ghc-9.4.0.20220501: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Utils.Monad.State.Lazy

Contents

- The State monda
- Operations

Description

A lazy state monad.

Synopsis

- data State s a where
  - pattern State :: (s -> (# a, s #)) -> State s a
- state :: (s -> (a, s)) -> State s a
- evalState :: State s a -> s -> a
- execState :: State s a -> s -> s
- runState :: State s a -> s -> (a, s)
- get :: State s s
- gets :: (s -> a) -> State s a
- put :: s -> State s ()
- modify :: (s -> s) -> State s ()

# The State monda

data State s a where Source #

A state monad which is lazy in the state.

Bundled Patterns

pattern State :: (s -> (# a, s #)) -> State s a |

#### Instances

Instances details

Applicative (State s) Source # |
Instance details Defined in GHC.Utils.Monad.State.Lazy Methods pure :: a -> State s a Source # (<*>) :: State s (a -> b) -> State s a -> State s b Source # liftA2 :: (a -> b -> c) -> State s a -> State s b -> State s c Source # (*>) :: State s a -> State s b -> State s b Source # (<*) :: State s a -> State s b -> State s a Source #
Functor (State s) Source # |
Instance details Defined in GHC.Utils.Monad.State.Lazy Methods fmap :: (a -> b) -> State s a -> State s b Source # (<$) :: a -> State s b -> State s a Source #
Monad (State s) Source # |
Instance details Defined in GHC.Utils.Monad.State.Lazy Methods (>>=) :: State s a -> (a -> State s b) -> State s b Source # (>>) :: State s a -> State s b -> State s b Source # return :: a -> State s a Source #

state :: (s -> (a, s)) -> State s a Source #

evalState :: State s a -> s -> a Source #

execState :: State s a -> s -> s Source #

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

# Operations

get :: State s s Source #

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

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

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