GHC.Utils.Monad.State.Strict

ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Utils.Monad.State.Strict

Contents

- The State monad
- Operations

Description

A state monad which is strict in its state.

Synopsis

- newtype State s a where
  - State' (s -> (# a, s #))
  - 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 monad

newtype State s a #

A state monad which is strict in the state `s`, but lazy in the value `a`.

See Note [Strict State monad] for the particular notion of strictness and implementation details.

Constructors

State' (s -> (# a, s #)) |

Bundled Patterns

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

#### Instances

Instances details

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

# Operations

get :: State s s #

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

put :: s -> State s () #

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