| Copyright | (C) 2014-2026 Edward Kmett |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Stability | provisional |
| Portability | non-portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Control.Monad.Primitive.Lens
Description
ReifiedIsos witnessing the isomorphisms offered by Control.Monad.Primitive.
The generic conversion between two PrimBase monads that share a
PrimState (that is, primToPrim or liftPrim) is not given its own
name here: it is simply prim composed with its own reverse. See prim.
The unsafe* conversions in Control.Monad.Primitive are deliberately
omitted: they coerce between monads with different PrimState tokens,
and so do not form lawful ReifiedIsos.
Synopsis
- prim :: PrimBase m => Iso (m a) (m b) (State# (PrimState m) -> (# State# (PrimState m), a #)) (State# (PrimState m) -> (# State# (PrimState m), b #))
- st :: PrimBase m => Iso (m a) (m b) (ST (PrimState m) a) (ST (PrimState m) b)
- io :: (PrimBase m, PrimState m ~ RealWorld) => Iso (m a) (m b) (IO a) (IO b)
Documentation
prim :: PrimBase m => Iso (m a) (m b) (State# (PrimState m) -> (# State# (PrimState m), a #)) (State# (PrimState m) -> (# State# (PrimState m), b #)) Source #
An ReifiedIso between a PrimBase monad and its underlying primitive
state-transformer representation.
viewprim≡internalreviewprim≡primitive
Composing this ReifiedIso with its own reverse is the bidirectional
PrimBase-to-PrimBase specialization of primToPrim (or liftPrim),
converting directly between any two PrimBase monads that share a
PrimState token. st and io compose the same way.
prim.fromprim:: (PrimBasem,PrimBasen,PrimStatem ~PrimStaten) =>ReifiedIso(m a) (m b) (n a) (n b)
>>>(pure 5 :: ST RealWorld Int) ^. prim . from prim :: IO Int5