-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more helper functions for working with (type-level) metadata #54
Comments
I tried looking at this briefly while at the Budapest Haskell Hackathon. Unfortunately, naming issues hit again. Let me try to organize my thoughts a bit. Currently, we have the following identifiers: -- term level metadata:
data DatatypeInfo :: [[*]] -> *
data ConstructorInfo :: [*] -> *
data FieldInfo :: * -> *
type ModuleName = String
type DatatypeName = String
type ConstructorName = String
type FieldName = String
moduleName :: DatatypeInfo xss -> ModuleName
datatypeName :: DatatypeInfo xss -> DatatypeName
constructorInfo :: DatatypeInfo xss -> NP ConstructorInfo xss
constructorName :: ConstructorInfo xs -> ConstructorName
fieldName :: FieldInfo a -> FieldName
datatypeInfo :: HasDatatypeInfo a => proxy a -> DatatypeInfo (Code a)
-- type level metadata:
kind T.DatatypeInfo :: *
kind T.ConstructorInfo :: *
kind T.FieldInfo :: *
type T.DatatypeName = Symbol -- unfortunately works only in GHC >= 8
type T.ModuleName = Symbol -- unfortunately works only in GHC >= 8
type T.ConstructorName = Symbol -- unfortunately works only in GHC >= 8
type T.FieldName = Symbol -- unfortunately works only in GHC >= 8
class T.DemoteDatatypeInfo :: T.DatatypeInfo -> [[*]] -> Constraint
class T.DemoteConstructorInfos :: [T.ConstructorInfo] -> [[*]] -> Constraint
class T.DemoteConstructorInfo :: T.ConstructorInfo -> [*] -> Constraint
class T.DemoteFieldInfos :: [T.FieldInfo] -> [*] -> Constraint
class T.DemoteFieldInfo :: T.FieldInfo -> * -> Constraint
type family DatatypeInfoOf :: * -> T.DatatypeInfo I would like to add type-level equivalents of type family GetModuleName :: T.DatatypeInfo -> T.ModuleName
type family GetDatatypeName :: T.DatatypeInfo -> T.DatatypeName
type family GetConstructorInfo :: T.DatatypeInfo -> [T.ConstructorInfo]
type family GetConstructorName :: T.ConstructorInfo -> T.ConstructorName
type family GetFieldName :: T.FieldInfo -> T.FieldName
Thoughts welcome. |
See #53 for some examples.
fieldNames
would be nice to have on the term-level.IsRecordType
would be nice to have on the type-level.But also type functions for operating on / extracting aspects of the type-level metadata structure would probably be useful. E.g. type-level equivalents of
moduleName
,datatypeName
,constructorInfo
,constructorName
,fieldName
.The text was updated successfully, but these errors were encountered: