Copyright | (c) L. S. Leary 2025 |
---|---|
Safe Haskell | None |
Language | GHC2021 |
Data.Hetero.PtrEq
Contents
Description
Heterogeneous pointer equality.
The offerings of this module should eventually be incorporated into base, stm and primitive by:
- Generalising the types of pointer equality primitives (#24994)
- Thereby providing
TestCoercion
instances for the the boxings of those primitive types (#17076) - Thereby providing
TestCoercion
instances for derived types
Synopsis
- data Array# (a :: TYPE ('BoxedRep l)) :: UnliftedType
- sameArray# :: forall {l :: Levity} (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). Array# a -> Array# b -> Maybe (Coercion a b)
- data MutableArray# a (b :: TYPE ('BoxedRep l)) :: UnliftedType
- sameMutableArray# :: forall {l :: Levity} s (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). MutableArray# s a -> MutableArray# s b -> Maybe (Coercion a b)
- data SmallArray# (a :: TYPE ('BoxedRep l)) :: UnliftedType
- sameSmallArray# :: forall {l :: Levity} (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). SmallArray# a -> SmallArray# b -> Maybe (Coercion a b)
- data SmallMutableArray# a (b :: TYPE ('BoxedRep l)) :: UnliftedType
- sameSmallMutableArray# :: forall {l :: Levity} s (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). SmallMutableArray# s a -> SmallMutableArray# s b -> Maybe (Coercion a b)
- data MutVar# a (b :: TYPE ('BoxedRep l)) :: UnliftedType
- sameMutVar# :: forall {l :: Levity} s (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). MutVar# s a -> MutVar# s b -> Maybe (Coercion a b)
- data TVar# a (b :: TYPE ('BoxedRep l)) :: UnliftedType
- sameTVar# :: forall {l :: Levity} s (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). TVar# s a -> TVar# s b -> Maybe (Coercion a b)
- data MVar# a (b :: TYPE ('BoxedRep l)) :: UnliftedType
- sameMVar# :: forall {l :: Levity} s (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). MVar# s a -> MVar# s b -> Maybe (Coercion a b)
- data IOPort# a (b :: TYPE ('BoxedRep l)) :: UnliftedType
- sameIOPort# :: forall {l :: Levity} s (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). IOPort# s a -> IOPort# s b -> Maybe (Coercion a b)
- data PromptTag# a :: UnliftedType
- samePromptTag# :: PromptTag# a -> PromptTag# b -> Maybe (Coercion a b)
- data Chan a
- sameChan :: Chan a -> Chan b -> Maybe (Coercion a b)
- data TBQueue a
- sameTBQueue :: TBQueue a -> TBQueue b -> Maybe (Coercion a b)
- data TChan a
- sameTChan :: TChan a -> TChan b -> Maybe (Coercion a b)
- data TMVar a
- sameTMVar :: TMVar a -> TMVar b -> Maybe (Coercion a b)
- data TQueue a
- sameTQueue :: TQueue a -> TQueue b -> Maybe (Coercion a b)
Pointer Equality
Primitive
GHC.Exts provides pointer equality functions for primitive unlifted types of the form:
sameFoo# :: Foo# a -> Foo# a -> Int#
When appropriate, we generalise the above to:
sameFoo# :: Foo# a -> Foo# b -> Maybe (Coercion a b)
\[ \]
data Array# (a :: TYPE ('BoxedRep l)) :: UnliftedType #
data MutableArray# a (b :: TYPE ('BoxedRep l)) :: UnliftedType #
Arguments
:: forall {l :: Levity} s (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). MutableArray# s a | |
-> MutableArray# s b | |
-> Maybe (Coercion a b) |
data SmallArray# (a :: TYPE ('BoxedRep l)) :: UnliftedType #
Arguments
:: forall {l :: Levity} (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). SmallArray# a | |
-> SmallArray# b | |
-> Maybe (Coercion a b) |
data SmallMutableArray# a (b :: TYPE ('BoxedRep l)) :: UnliftedType #
sameSmallMutableArray# Source #
Arguments
:: forall {l :: Levity} s (a :: TYPE ('BoxedRep l)) (b :: TYPE ('BoxedRep l)). SmallMutableArray# s a | |
-> SmallMutableArray# s b | |
-> Maybe (Coercion a b) |
data MutVar# a (b :: TYPE ('BoxedRep l)) :: UnliftedType #
A MutVar#
behaves like a single-element mutable array.
data TVar# a (b :: TYPE ('BoxedRep l)) :: UnliftedType #
data MVar# a (b :: TYPE ('BoxedRep l)) :: UnliftedType #
data IOPort# a (b :: TYPE ('BoxedRep l)) :: UnliftedType #
A shared I/O port is almost the same as an MVar#
.
The main difference is that IOPort has no deadlock detection or
deadlock breaking code that forcibly releases the lock.
data PromptTag# a :: UnliftedType #
See GHC.Prim.
samePromptTag# :: PromptTag# a -> PromptTag# b -> Maybe (Coercion a b) Source #
Derived
There are various types in base and stm derived from the primitive types above, but for which opacity precludes leveraging the corresponding functions.
Accordingly, we provide additional sameFoo
functions for them here.
\[ \]
Chan
is an abstract type representing an unbounded FIFO channel.
TBQueue
is an abstract type representing a bounded FIFO channel.
Since: stm-2.4
TChan
is an abstract type representing an unbounded FIFO channel.
A TMVar
is a synchronising variable, used
for communication between concurrent threads. It can be thought of
as a box, which may be empty or full.