| Copyright | (C) 2011-2021 Edward Kmett |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Unsafe |
| Language | Haskell2010 |
Data.Constraint.Unsafe
Description
Unsafe utilities used throughout constraints. As the names suggest, these
functions are unsafe in general and can cause your program to segfault if
used improperly. Handle with care.
Synopsis
- class a ~R# b => Coercible (a :: k) (b :: k)
- unsafeAxiom :: Dict c
- unsafeCoerceConstraint :: a :- b
- unsafeDerive :: Coercible n o => (o -> n) -> t o :- t n
- unsafeUnderive :: Coercible n o => (o -> n) -> t n :- t o
- unsafeSChar :: forall (c :: Char). Char -> SChar c
- unsafeSNat :: forall (n :: Nat). Natural -> SNat n
- unsafeSSymbol :: forall (s :: Symbol). String -> SSymbol s
Documentation
unsafeAxiom :: Dict c Source #
Unsafely create a dictionary for any constraint.
unsafeCoerceConstraint :: a :- b Source #
Coerce a dictionary unsafely from one type to another
unsafeDerive :: Coercible n o => (o -> n) -> t o :- t n Source #
Coerce a dictionary unsafely from one type to a newtype of that type
unsafeUnderive :: Coercible n o => (o -> n) -> t n :- t o Source #
Coerce a dictionary unsafely from a newtype of a type to the base type
Unsafely creating GHC.TypeLits singleton values
unsafeSChar :: forall (c :: Char). Char -> SChar c Source #
Unsafely create an SChar value directly from a Char. Use this function
with care:
- The
Charvalue must match theCharcencoded in the return type.SCharc - Be wary of using this function to create multiple values of type
, whereSCharTTis a type family that does not reduce (e.g.,Anyfrom GHC.Exts). If you do, GHC is liable to optimize away one of the values and replace it with the other during a common subexpression elimination pass. If the two values have different underlyingCharvalues, this could be disastrous.
unsafeSNat :: forall (n :: Nat). Natural -> SNat n Source #
Unsafely create an SNat value directly from a Natural. Use this
function with care:
- The
Naturalvalue must match theNatnencoded in the return type.SNatn - Be wary of using this function to create multiple values of type
, whereSNatTTis a type family that does not reduce (e.g.,Anyfrom GHC.Exts). If you do, GHC is liable to optimize away one of the values and replace it with the other during a common subexpression elimination pass. If the two values have different underlyingNaturalvalues, this could be disastrous.
unsafeSSymbol :: forall (s :: Symbol). String -> SSymbol s Source #
Unsafely create an SSymbol value directly from a String. Use this
function with care:
- The
Stringvalue must match theSymbolsencoded in the return type.SSymbols - Be wary of using this function to create multiple values of type
, whereSSymbolTTis a type family that does not reduce (e.g.,Anyfrom GHC.Exts). If you do, GHC is liable to optimize away one of the values and replace it with the other during a common subexpression elimination pass. If the two values have different underlyingStringvalues, this could be disastrous.