Copyright | (c) Alexey Kuleshevich 2020 |
---|---|
License | BSD3 |
Maintainer | Alexey Kuleshevich <alexey@kuleshevi.ch> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data StableName a = StableName (StableName# a)
- makeStableName :: MonadPrim RW m => a -> m (StableName a)
- makeAnyStableName :: MonadPrim RW m => a -> m (StableName Any)
- hashStableName :: StableName a -> Int
- eqStableName :: StableName a -> StableName b -> Bool
Documentation
data StableName a #
An abstract name for an object, that supports equality and hashing.
Stable names have the following property:
- If
sn1 :: StableName
andsn2 :: StableName
andsn1 == sn2
thensn1
andsn2
were created by calls tomakeStableName
on the same object.
The reverse is not necessarily true: if two stable names are not
equal, then the objects they name may still be equal. Note in particular
that makeStableName
may return a different StableName
after an
object is evaluated.
Stable Names are similar to Stable Pointers (Foreign.StablePtr), but differ in the following ways:
- There is no
freeStableName
operation, unlike Foreign.StablePtrs. Stable names are reclaimed by the runtime system when they are no longer needed. - There is no
deRefStableName
operation. You can't get back from a stable name to the original Haskell object. The reason for this is that the existence of a stable name for an object does not guarantee the existence of the object itself; it can still be garbage collected.
Instances
NFData1 StableName | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq liftRnf :: (a -> ()) -> StableName a -> () # | |
Eq (StableName a) | Since: base-2.1 |
Defined in GHC.StableName (==) :: StableName a -> StableName a -> Bool # (/=) :: StableName a -> StableName a -> Bool # | |
Show (StableName a) Source # | Orphan instance defined in Data.Prim.StableName |
Defined in Data.Prim.StableName showsPrec :: Int -> StableName a -> ShowS # show :: StableName a -> String # showList :: [StableName a] -> ShowS # | |
NFData (StableName a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq rnf :: StableName a -> () # |
makeStableName :: MonadPrim RW m => a -> m (StableName a) Source #
Makes a StableName
for an arbitrary object. The object passed as
the first argument is not evaluated by makeStableName
.
makeAnyStableName :: MonadPrim RW m => a -> m (StableName Any) Source #
Similar to
makeDynamicStableName
,
but returns StableName
Any
and is generalized to MonadPrim
hashStableName :: StableName a -> Int #
Convert a StableName
to an Int
. The Int
returned is not
necessarily unique; several StableName
s may map to the same Int
(in practice however, the chances of this are small, so the result
of hashStableName
makes a good hash key).
eqStableName :: StableName a -> StableName b -> Bool #
Equality on StableName
that does not require that the types of
the arguments match.
Since: base-4.7.0.0
Orphan instances
Show (StableName a) Source # | Orphan instance defined in Data.Prim.StableName |
showsPrec :: Int -> StableName a -> ShowS # show :: StableName a -> String # showList :: [StableName a] -> ShowS # |