Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Metadata maintenance; usefull for pretty-printing values.
- type ModuleName = String
- type FamilyName = String
- type ConstructorName = String
- type FieldName = String
- data DatatypeName
- data DatatypeInfo :: [[Atom kon]] -> * where
- ADT :: ModuleName -> DatatypeName -> NP ConstructorInfo c -> DatatypeInfo c
- New :: ModuleName -> DatatypeName -> ConstructorInfo '[c] -> DatatypeInfo '['[c]]
- moduleName :: DatatypeInfo code -> ModuleName
- datatypeName :: DatatypeInfo code -> DatatypeName
- constructorInfo :: DatatypeInfo code -> NP ConstructorInfo code
- data Associativity
- type Fixity = Int
- data ConstructorInfo :: [Atom kon] -> * where
- Constructor :: ConstructorName -> ConstructorInfo xs
- Infix :: ConstructorName -> Associativity -> Fixity -> ConstructorInfo '[x, y]
- Record :: ConstructorName -> NP FieldInfo xs -> ConstructorInfo xs
- constructorName :: ConstructorInfo con -> ConstructorName
- data FieldInfo :: Atom kon -> * where
- class Family ki fam codes => HasDatatypeInfo ki fam codes ix | fam -> codes ki where
- datatypeInfoFor :: forall ki fam codes ix ty. (HasDatatypeInfo ki fam codes ix, ix ~ Idx ty fam, Lkup ix fam ~ ty, IsNat ix) => Proxy fam -> Proxy ty -> DatatypeInfo (Lkup ix codes)
- constrInfoLkup :: Constr sum c -> DatatypeInfo sum -> ConstructorInfo (Lkup c sum)
Documentation
type ModuleName = String Source #
type FamilyName = String Source #
type ConstructorName = String Source #
data DatatypeName Source #
Since we only handled fully saturated datatypes, a DatatypeName
needs to remember what were the arguments applied to a type.
The type [Int]
is represented by Name "[]" :
: Name Int
Name String | |
DatatypeName :@: DatatypeName infixl 5 |
data DatatypeInfo :: [[Atom kon]] -> * where Source #
Provides information about the declaration of a datatype.
ADT :: ModuleName -> DatatypeName -> NP ConstructorInfo c -> DatatypeInfo c | |
New :: ModuleName -> DatatypeName -> ConstructorInfo '[c] -> DatatypeInfo '['[c]] |
Show (DatatypeInfo kon code) Source # | |
moduleName :: DatatypeInfo code -> ModuleName Source #
datatypeName :: DatatypeInfo code -> DatatypeName Source #
constructorInfo :: DatatypeInfo code -> NP ConstructorInfo code Source #
data Associativity Source #
Associativity information for infix constructors.
data ConstructorInfo :: [Atom kon] -> * where Source #
Constructor metadata.
Constructor :: ConstructorName -> ConstructorInfo xs | |
Infix :: ConstructorName -> Associativity -> Fixity -> ConstructorInfo '[x, y] | |
Record :: ConstructorName -> NP FieldInfo xs -> ConstructorInfo xs |
Show (ConstructorInfo kon code) Source # | |
Show (NP [Atom kon] (ConstructorInfo kon) code) Source # | |
constructorName :: ConstructorInfo con -> ConstructorName Source #
class Family ki fam codes => HasDatatypeInfo ki fam codes ix | fam -> codes ki where Source #
Given a Family
, provides the DatatypeInfo
for the type
with index ix
in family fam
.
datatypeInfo :: IsNat ix => Proxy fam -> Proxy ix -> DatatypeInfo (Lkup ix codes) Source #
datatypeInfoFor :: forall ki fam codes ix ty. (HasDatatypeInfo ki fam codes ix, ix ~ Idx ty fam, Lkup ix fam ~ ty, IsNat ix) => Proxy fam -> Proxy ty -> DatatypeInfo (Lkup ix codes) Source #
Sometimes it is more convenient to use a proxy of the type in the family instead of indexes.
Name Lookup
constrInfoLkup :: Constr sum c -> DatatypeInfo sum -> ConstructorInfo (Lkup c sum) Source #
This is essentially a list lookup, but needs significant type
information to go through. Returns the name of the c
th constructor
of a sum-type.