Copyright | (c) Galois Inc 2014-2015 |
---|---|
Maintainer | Joe Hendrix <jhendrix@galois.com> |
Safe Haskell | Trustworthy |
Language | Haskell98 |
This defines a type family SymbolRepr
for representing a type-level string
(AKA symbol) at runtime. This can be used to branch on a type-level value.
The TestEquality
and OrdF
instances for SymbolRepr
are implemented using
unsafeCoerce
. This should be typesafe because we maintain the invariant
that the string value contained in a SymbolRepr value matches its static type.
At the type level, symbols have very few operations, so SymbolRepr correspondingly has very few functions that manipulate them.
- data SymbolRepr (nm :: Symbol)
- symbolRepr :: SymbolRepr nm -> Text
- knownSymbol :: KnownSymbol s => SymbolRepr s
- someSymbol :: Text -> Some SymbolRepr
- data Symbol :: *
- class KnownSymbol (n :: Symbol)
SymbolRepr
data SymbolRepr (nm :: Symbol) Source #
A runtime representation of a GHC type-level symbol.
TestEquality Symbol SymbolRepr Source # | |
HashableF Symbol SymbolRepr Source # | |
ShowF Symbol SymbolRepr Source # | |
OrdF Symbol SymbolRepr Source # | |
KnownSymbol s => KnownRepr Symbol SymbolRepr s Source # | |
Eq (SymbolRepr x) Source # | |
Ord (SymbolRepr x) Source # | |
Show (SymbolRepr nm) Source # | |
Hashable (SymbolRepr nm) Source # | |
symbolRepr :: SymbolRepr nm -> Text Source #
The underlying text representation of the symbol
knownSymbol :: KnownSymbol s => SymbolRepr s Source #
Generate a value representative for the type level symbol.
someSymbol :: Text -> Some SymbolRepr Source #
Generate a symbol representative at runtime. The type-level
symbol will be abstract, as it is hidden by the Some
constructor.
Re-exports
(Kind) This is the kind of type-level symbols. Declared here because class IP needs it
SingKind Symbol | Since: 4.9.0.0 |
KnownSymbol a => SingI Symbol a | Since: 4.9.0.0 |
TestEquality Symbol SymbolRepr # | |
HashableF Symbol SymbolRepr Source # | |
ShowF Symbol SymbolRepr Source # | |
OrdF Symbol SymbolRepr Source # | |
KnownSymbol n => Reifies Symbol n String | |
KnownSymbol s => KnownRepr Symbol SymbolRepr s Source # | |
data Sing Symbol | |
type DemoteRep Symbol | |
type (==) Symbol a b | |
class KnownSymbol (n :: Symbol) #
This class gives the string associated with a type-level symbol. There are instances of the class for every concrete literal: "hello", etc.
Since: 4.7.0.0
symbolSing