constraints-0.14: Constraint manipulation
Copyright(C) 2011-2021 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellUnsafe
LanguageHaskell2010

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

Documentation

class a ~R# b => Coercible (a :: k) (b :: k) #

Instances

Instances details
HasDict (Coercible a b) (Coercion a b) # 
Instance details

Defined in Data.Constraint

Methods

evidence :: Coercion a b -> Dict (Coercible a b) #

unsafeAxiom :: Dict c #

Unsafely create a dictionary for any constraint.

unsafeCoerceConstraint :: a :- b #

Coerce a dictionary unsafely from one type to another

unsafeDerive :: Coercible n o => (o -> n) -> t o :- t n #

Coerce a dictionary unsafely from one type to a newtype of that type

unsafeUnderive :: Coercible n o => (o -> n) -> t n :- t o #

Coerce a dictionary unsafely from a newtype of a type to the base type

Unsafely creating GHC.TypeLits singleton values

unsafeSChar :: Char -> SChar c #

Unsafely create an SChar value directly from a Char. Use this function with care:

  • The Char value must match the Char c encoded in the return type SChar c.
  • Be wary of using this function to create multiple values of type SChar T, where T is a type family that does not reduce (e.g., Any from 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 underlying Char values, this could be disastrous.

unsafeSNat :: Natural -> SNat n #

Unsafely create an SNat value directly from a Natural. Use this function with care:

  • The Natural value must match the Nat n encoded in the return type SNat n.
  • Be wary of using this function to create multiple values of type SNat T, where T is a type family that does not reduce (e.g., Any from 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 underlying Natural values, this could be disastrous.

unsafeSSymbol :: String -> SSymbol s #

Unsafely create an SSymbol value directly from a String. Use this function with care:

  • The String value must match the Symbol s encoded in the return type SSymbol s.
  • Be wary of using this function to create multiple values of type SSymbol T, where T is a type family that does not reduce (e.g., Any from 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 underlying String values, this could be disastrous.