capnp-0.17.0.0: Cap'n Proto for Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Capnp.Mutability

Synopsis

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 s denotes a value that can be mutated in the scope of the state token s.

Constructors

Const 
Mut Type 

class MaybeMutable (f :: Mutability -> Type) where Source #

MaybeMutable relates mutable and immutable versions of a type.

Minimal complete definition

thaw, freeze

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

Instances details
MaybeMutable Message Source # 
Instance details

Defined in Capnp.Message

Methods

thaw :: (PrimMonad m, PrimState m ~ s) => Message 'Const -> m (Message ('Mut s)) Source #

freeze :: (PrimMonad m, PrimState m ~ s) => Message ('Mut s) -> m (Message 'Const) Source #

unsafeThaw :: (PrimMonad m, PrimState m ~ s) => Message 'Const -> m (Message ('Mut s)) Source #

unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => Message ('Mut s) -> m (Message 'Const) Source #

MaybeMutable Segment Source # 
Instance details

Defined in Capnp.Message

Methods

thaw :: (PrimMonad m, PrimState m ~ s) => Segment 'Const -> m (Segment ('Mut s)) Source #

freeze :: (PrimMonad m, PrimState m ~ s) => Segment ('Mut s) -> m (Segment 'Const) Source #

unsafeThaw :: (PrimMonad m, PrimState m ~ s) => Segment 'Const -> m (Segment ('Mut s)) Source #

unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => Segment ('Mut s) -> m (Segment 'Const) Source #

MaybeMutable Cap Source # 
Instance details

Defined in Capnp.Untyped

Methods

thaw :: (PrimMonad m, PrimState m ~ s) => Cap 'Const -> m (Cap ('Mut s)) Source #

freeze :: (PrimMonad m, PrimState m ~ s) => Cap ('Mut s) -> m (Cap 'Const) Source #

unsafeThaw :: (PrimMonad m, PrimState m ~ s) => Cap 'Const -> m (Cap ('Mut s)) Source #

unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => Cap ('Mut s) -> m (Cap 'Const) Source #

MaybeMutable List Source # 
Instance details

Defined in Capnp.Untyped

Methods

thaw :: (PrimMonad m, PrimState m ~ s) => List 'Const -> m (List ('Mut s)) Source #

freeze :: (PrimMonad m, PrimState m ~ s) => List ('Mut s) -> m (List 'Const) Source #

unsafeThaw :: (PrimMonad m, PrimState m ~ s) => List 'Const -> m (List ('Mut s)) Source #

unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => List ('Mut s) -> m (List 'Const) Source #

MaybeMutable MaybePtr Source # 
Instance details

Defined in Capnp.Untyped

Methods

thaw :: (PrimMonad m, PrimState m ~ s) => MaybePtr 'Const -> m (MaybePtr ('Mut s)) Source #

freeze :: (PrimMonad m, PrimState m ~ s) => MaybePtr ('Mut s) -> m (MaybePtr 'Const) Source #

unsafeThaw :: (PrimMonad m, PrimState m ~ s) => MaybePtr 'Const -> m (MaybePtr ('Mut s)) Source #

unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => MaybePtr ('Mut s) -> m (MaybePtr 'Const) Source #

MaybeMutable Ptr Source # 
Instance details

Defined in Capnp.Untyped

Methods

thaw :: (PrimMonad m, PrimState m ~ s) => Ptr 'Const -> m (Ptr ('Mut s)) Source #

freeze :: (PrimMonad m, PrimState m ~ s) => Ptr ('Mut s) -> m (Ptr 'Const) Source #

unsafeThaw :: (PrimMonad m, PrimState m ~ s) => Ptr 'Const -> m (Ptr ('Mut s)) Source #

unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => Ptr ('Mut s) -> m (Ptr 'Const) Source #

MaybeMutable Struct Source # 
Instance details

Defined in Capnp.Untyped

Methods

thaw :: (PrimMonad m, PrimState m ~ s) => Struct 'Const -> m (Struct ('Mut s)) Source #

freeze :: (PrimMonad m, PrimState m ~ s) => Struct ('Mut s) -> m (Struct 'Const) Source #

unsafeThaw :: (PrimMonad m, PrimState m ~ s) => Struct 'Const -> m (Struct ('Mut s)) Source #

unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => Struct ('Mut s) -> m (Struct 'Const) Source #

ReprMaybeMutable (ReprFor a) => MaybeMutable (Raw a) Source # 
Instance details

Defined in Capnp.Repr

Methods

thaw :: (PrimMonad m, PrimState m ~ s) => Raw a 'Const -> m (Raw a ('Mut s)) Source #

freeze :: (PrimMonad m, PrimState m ~ s) => Raw a ('Mut s) -> m (Raw a 'Const) Source #

unsafeThaw :: (PrimMonad m, PrimState m ~ s) => Raw a 'Const -> m (Raw a ('Mut s)) Source #

unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => Raw a ('Mut s) -> m (Raw a 'Const) Source #

MaybeMutable (IgnoreMut a) Source # 
Instance details

Defined in Capnp.Untyped

Methods

thaw :: (PrimMonad m, PrimState m ~ s) => IgnoreMut a 'Const -> m (IgnoreMut a ('Mut s)) Source #

freeze :: (PrimMonad m, PrimState m ~ s) => IgnoreMut a ('Mut s) -> m (IgnoreMut a 'Const) Source #

unsafeThaw :: (PrimMonad m, PrimState m ~ s) => IgnoreMut a 'Const -> m (IgnoreMut a ('Mut s)) Source #

unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => IgnoreMut a ('Mut s) -> m (IgnoreMut a 'Const) Source #

MaybeMutable (ListRepOf r) => MaybeMutable (ListOf r) Source # 
Instance details

Defined in Capnp.Untyped

Methods

thaw :: (PrimMonad m, PrimState m ~ s) => ListOf r 'Const -> m (ListOf r ('Mut s)) Source #

freeze :: (PrimMonad m, PrimState m ~ s) => ListOf r ('Mut s) -> m (ListOf r 'Const) Source #

unsafeThaw :: (PrimMonad m, PrimState m ~ s) => ListOf r 'Const -> m (ListOf r ('Mut s)) Source #

unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => ListOf r ('Mut s) -> m (ListOf r 'Const) Source #

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.