| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
Capnp.Mutability
Synopsis
- data Mutability
- class MaybeMutable (f :: Mutability -> Type) where
- create :: MaybeMutable f => (forall s. ST s (f ('Mut s))) -> f 'Const
- createT :: (Traversable t, MaybeMutable f) => (forall s. ST s (t (f ('Mut s)))) -> t (f 'Const)
Documentation
data Mutability Source #
Mutability is used as a type parameter (with the DataKinds extension)
 to indicate the mutability of some values in this library; Const denotes
 an immutable value, while Mut ss.
class MaybeMutable (f :: Mutability -> Type) where Source #
MaybeMutable relates mutable and immutable versions of a type.
Methods
thaw :: (PrimMonad m, PrimState m ~ s) => f 'Const -> m (f ('Mut s)) Source #
Convert an immutable value to a mutable one.
freeze :: (PrimMonad m, PrimState m ~ s) => f ('Mut s) -> m (f 'Const) Source #
Convert a mutable value to an immutable one.
unsafeThaw :: (PrimMonad m, PrimState m ~ s) => f 'Const -> m (f ('Mut s)) Source #
Like thaw, except that the caller is responsible for ensuring that
 the original value is not subsequently used; doing so may violate
 referential transparency.
The default implementation of this is just the same as thaw, but
 typically an instance will override this with a trivial (unsafe) cast,
 hence the obligation described above.
unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => f ('Mut s) -> m (f 'Const) Source #
Unsafe version of freeze analagous to unsafeThaw. The caller must
 ensure that the original value is not used after this call.
Instances
create :: MaybeMutable f => (forall s. ST s (f ('Mut s))) -> f 'Const Source #
Create and freeze a mutable value, safely, without doing a full copy.
 internally, create calls unsafeFreeze, but it cannot be directly used to
 violate referential transparency, as the value is not available to the
 caller after freezing.
createT :: (Traversable t, MaybeMutable f) => (forall s. ST s (t (f ('Mut s)))) -> t (f 'Const) Source #
Like create, but the result is wrapped in an instance of Traversable.