Version of bracket with an INLINE pragma to work around https://gitlab.haskell.org/ghc/ghc/-/issues/22824.
Moduleeffectful-core-2.7.1.2GHC2021
Effectful.Internal.Utils
- 1 type
- 8 values
- Packageeffectful-core-2.7.1.2
- Exports10
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceUtils.hs
Utils for ThreadId
1 declarationGet an id of a thread that doesn't prevent its garbage collection.
Utils for Any
3 declarationsThe type constructor Any :: forall k. k allows creating an arbitrary type
of the given kind.
It can be used to create a placeholder type when you only have a kind in hand.
You can use unsafeCoerce# to unsafely coerce a value from ty :: k to Any @k
and back. As per the documentation of unsafeCoerce#, this is only sound if both
sides have the exact sameruntime representation. Some examples:
unsafeCoerce# True :: (Any :: Type) -- OK
unsafeCoerce# (1# :: Int#) :: (Any :: TYPE IntRep) -- OK
unsafeCoerce# True :: (Any :: Type IntRep) -- INVALID
unsafeCoerce True :: (Any :: UnliftedType) -- INVALID
unsafeCoerce (ba :: ByteArray#) :: (Any :: Type) -- INVALID
To avoid accidentally unsafe-coercing between different representations,
it is recommended to:
- use explicit type annotations or type applications at every use-site
of unsafeCoerce#
- use representation-monomorphic variants such as unsafeCoerce or
unsafeCoerceUnlifted.
In particular, this also implies it is safe to round-trip unsafe-coercion via Any,
as long as the kinds line up e.g. unsafeCoerce (unsafeCoerce (val :: a) :: Any) :: a
is safe in that way.
Unique
2 declarationsA unique with no possibility for CAS contention.
Credits for this go to Edward Kmett.
CallStack
1 declarationRemove exactly one layer of freezing, i.e. the one added by send and
friends via withFrozenCallStack. Freezes applied by client code need to
stay intact, so this must not recurse.
Array capacity
1 declarationGrow capacity of an array.
Utils for MutablePrimArray
1 declarationfillPrimArray Fill a slice of a mutable primitive array with a value.