Safe Haskell | Unsafe |
---|
Data.PhaseChange.Impl
Description
This module allows you to write instances for PhaseChangeable types. To work with PhaseChangeable data, see Data.PhaseChange. For unsafe functions, see Data.PhaseChange.Unsafe.
- class (Thawed imm ~ mut, Frozen mut ~ imm) => PhaseChange imm mut where
- type Thawed imm :: * -> *
- type Frozen mut :: *
- unsafeThawImpl :: imm -> ST s (Thawed imm s)
- unsafeFreezeImpl :: mut s -> ST s (Frozen mut)
- copyImpl :: mut s -> ST s (mut s)
- newtype M1 mut a s = M1 {
- unM1 :: mut s a
- newtype M2 mut a b s = M2 {
- unM2 :: mut s a b
Documentation
class (Thawed imm ~ mut, Frozen mut ~ imm) => PhaseChange imm mut whereSource
The PhaseChange
class ties together types which provide a mutable and an immutable view
on the same data. The mutable type must have a phantom type parameter representing the
state thread it is being used in. Many types have this type parameter in the wrong place
(not at the end): instances for them can be provided using the
and M1
newtypes.
M2
Methods
unsafeThawImpl :: imm -> ST s (Thawed imm s)Source
Should return the same data it got as input, viewed as a mutable type, making no changes.
unsafeFreezeImpl :: mut s -> ST s (Frozen mut)Source
Should return the same data it got as input, viewed as an immutable type, making no changes.
copyImpl :: mut s -> ST s (mut s)Source
Should make a perfect copy of the input argument, leaving nothing shared between the original and the copy, and making no other changes.
Instances
PhaseChange ByteArray MutableByteArray | Data.Primitive.ByteArray |
PhaseChange (Array a) (M1 MutableArray a) | Data.Primitive.Array |
PhaseChange (Vector a) (M1 MVector a) | Data.Vector |
Unbox a => PhaseChange (Vector a) (M1 MVector a) | Data.Vector.Unboxed |
Storable a => PhaseChange (Vector a) (M1 MVector a) | Data.Vector.Storable |
Prim a => PhaseChange (Vector a) (M1 MVector a) | Data.Vector.Primitive |
(Ix i, IArray UArray a, MArray (STUArray S) a (ST S)) => PhaseChange (UArray i a) (M2 STUArray i a) | Data.Array.Unboxed |
(Ix i, IArray Array a, MArray (STArray S) a (ST S)) => PhaseChange (Array i a) (M2 STArray i a) | Data.Array |
Newtype for mutable types whose state thread parameter is in the second-to-last position
Instances
PhaseChange (Array a) (M1 MutableArray a) | Data.Primitive.Array |
PhaseChange (Vector a) (M1 MVector a) | Data.Vector |
Unbox a => PhaseChange (Vector a) (M1 MVector a) | Data.Vector.Unboxed |
Storable a => PhaseChange (Vector a) (M1 MVector a) | Data.Vector.Storable |
Prim a => PhaseChange (Vector a) (M1 MVector a) | Data.Vector.Primitive |
Newtype for mutable types whose state thread parameter is in the third-to-last position