Copyright | (C) 2019 Myrtle Software Ltd 2021 QBayLogic B.V. 2022 Google Inc. |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
Safe Haskell | None |
Language | Haskell2010 |
Tools to convert a Term
into its "real" representation
Synopsis
- class TermLiteral a
- showsTypePrec :: TermLiteral a => Int -> Proxy a -> ShowS
- showType :: TermLiteral a => Proxy a -> String
- termToData :: (TermLiteral a, HasCallStack) => Term -> Either Term a
- termToDataError :: forall a. TermLiteral a => Term -> Either String a
- deriveTermLiteral :: Name -> Q [Dec]
Documentation
class TermLiteral a Source #
Tools to deal with literals encoded as a Term
.
Instances
:: TermLiteral a | |
=> Int | The operator precedence of the enclosing context (a number from |
-> Proxy a | Proxy for a term whose type needs to be pretty printed |
-> ShowS |
Pretty print the type of a term (for error messages). Its default implementation
uses Typeable
to print the type. Note that this method is there to allow
an instance for SNat
to exist (and other GADTs imposing
KnownNat
). Without it, GHC would ask for a KnownNat
constraint on the instance, which would defeat the purpose of it.
:: (TermLiteral a, HasCallStack) | |
=> Term | Term to convert |
-> Either Term a |
|
Convert Term
to the constant it represents. Will return an error if
(one of the subterms) fail to translate.
termToDataError :: forall a. TermLiteral a => Term -> Either String a Source #
Same as termToData
, but returns printable error message if it couldn't
translate a term.
deriveTermLiteral :: Name -> Q [Dec] Source #
Derive a TermLiteral
instance for given type