modify -package:mtl
modify f is an action that updates the state to the
result of applying
f to the current state.
modify f is an action that updates the state to the
result of applying
f to the current state.
modify f is an action that updates the state to the
result of applying
f to the current state.
Apply a destructive operation to a vector. The operation may be
performed in place if it is safe to do so and will modify a copy of
the vector otherwise (see
New for details).
Examples
>>> import qualified Data.Vector as V
>>> import qualified Data.Vector.Mutable as MV
>>> V.modify (\v -> MV.write v 0 'x') $ V.replicate 4 'a'
"xaaa"
Apply a destructive operation to a vector. The operation may be
performed in place if it is safe to do so and will modify a copy of
the vector otherwise (see
New for details).
Examples
>>> import qualified Data.Vector.Strict as V
>>> import qualified Data.Vector.Strict.Mutable as MV
>>> V.modify (\v -> MV.write v 0 'x') $ V.replicate 4 'a'
"xaaa"
Modify the element at the given position.
Modify the element at the given position.
Apply a destructive operation to a vector. The operation may be
performed in place if it is safe to do so and will modify a copy of
the vector otherwise (see
New for details).
Examples
>>> import qualified Data.Vector.Primitive as VP
>>> import qualified Data.Vector.Primitive.Mutable as MVP
>>> VP.modify (\v -> MVP.write v 0 'x') $ VP.replicate 4 'a'
"xaaa"
Modify the element at the given position.
Apply a destructive operation to a vector. The operation may be
performed in place if it is safe to do so and will modify a copy of
the vector otherwise (see
New for details).
Examples
>>> import qualified Data.Vector.Storable as VS
>>> import qualified Data.Vector.Storable.Mutable as MVS
>>> VS.modify (\v -> MVS.write v 0 'x') $ VS.replicate 4 'a'
"xaaa"
Modify the element at the given position.
Apply a destructive operation to a vector. The operation may be
performed in place if it is safe to do so and will modify a copy of
the vector otherwise (see
New for details).
Examples
>>> import qualified Data.Vector.Unboxed as VU
>>> import qualified Data.Vector.Unboxed.Mutable as MVU
>>> VU.modify (\v -> MVU.write v 0 'x') $ VU.replicate 4 'a'
"xaaa"
Modify the element at the given position.
Monadic state transformer.
Maps an old state to a new state inside a state monad. The old state
is thrown away.
Main> :t modify ((+1) :: Int -> Int)
modify (...) :: (MonadState Int a) => a ()
This says that
modify (+1) acts over any Monad that is a
member of the
MonadState class, with an
Int state.
Apply a destructive operation to a vector. The operation will be
performed in place if it is safe to do so and will modify a copy of
the vector otherwise.
modify (\v -> write v 0 'x') (replicate 3 'a') = <'x','a','a'>
Apply a destructive operation to a vector. The operation will be
performed in place if it is safe to do so and will modify a copy of
the vector otherwise.
modify (\v -> write v 0 'x') (replicate 3 'a') = <'x','a','a'>
Apply a destructive operation to a vector. The operation will be
performed in place if it is safe to do so and will modify a copy of
the vector otherwise.
modify (\v -> write v 0 'x') (replicate 3 'a') = <'x','a','a'>
Apply a destructive operation to a vector. The operation will be
performed in place if it is safe to do so and will modify a copy of
the vector otherwise.
modify (\v -> write v 0 'x') (replicate 3 'a') = <'x','a','a'>
Monadic state transformer.
Maps an old state to a new state inside a state monad. The old state
is thrown away.
Main> :t modify ((+1) :: Int -> Int)
modify (...) :: (MonadState Int a) => a ()
This says that
modify (+1) acts over any Monad that is a
member of the
MonadState class, with an
Int state.
Transform the value of a field by a function.
Set the label to the result of applying the given function to the
value.