| Copyright | (c) Sirui Lu 2024 |
|---|---|
| License | BSD-3-Clause (see the LICENSE file) |
| Maintainer | siruilu@cs.washington.edu |
| Stability | Experimental |
| Portability | GHC only |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Grisette.TH
Description
Synopsis
- data EvalModeConfig
- data DeriveConfig = DeriveConfig {}
- deriveGADT :: [Name] -> [Name] -> Q [Dec]
- deriveGADTWith :: DeriveConfig -> [Name] -> [Name] -> Q [Dec]
- allClasses0 :: [Name]
- allClasses01 :: [Name]
- allClasses012 :: [Name]
- basicClasses0 :: [Name]
- noExistentialClasses0 :: [Name]
- ordClasses0 :: [Name]
- basicClasses1 :: [Name]
- noExistentialClasses1 :: [Name]
- ordClasses1 :: [Name]
- basicClasses2 :: [Name]
- noExistentialClasses2 :: [Name]
- ordClasses2 :: [Name]
- makePrefixedSmartCtor :: String -> Name -> Q [Dec]
- makeNamedSmartCtor :: [String] -> Name -> Q [Dec]
- makeSmartCtor :: Name -> Q [Dec]
- makeSmartCtorWith :: (String -> String) -> Name -> Q [Dec]
- makePrefixedUnifiedCtor :: [Name] -> String -> Name -> Q [Dec]
- makeNamedUnifiedCtor :: [Name] -> [String] -> Name -> Q [Dec]
- makeUnifiedCtor :: [Name] -> Name -> Q [Dec]
- makeUnifiedCtorWith :: [Name] -> (String -> String) -> Name -> Q [Dec]
Convenient derivation of all instances relating to Grisette
data EvalModeConfig Source #
Configuration for constraints for evaluation modes tag.
EvalModeConstraintsspecifies a list of constraints for the tag, for example, we may useEvalModeBaseandEvalModeBVto specify that the evaluation mode must support both base (boolean and data types) and bit vectors. This should be used when the data type uses bit vectors.EvalModeSpecifiedspecifies a that an evaluation mode tag should be specialized to a specific tag for all the instances.
Constructors
| EvalModeConstraints [Name] | |
| EvalModeSpecified EvalModeTag |
data DeriveConfig Source #
Configuration for deriving instances for a GADT.
Constructors
| DeriveConfig | |
Fields | |
Instances
| Monoid DeriveConfig Source # | |
Defined in Grisette.Internal.TH.GADT.Common Methods mempty :: DeriveConfig # mappend :: DeriveConfig -> DeriveConfig -> DeriveConfig # mconcat :: [DeriveConfig] -> DeriveConfig # | |
| Semigroup DeriveConfig Source # | |
Defined in Grisette.Internal.TH.GADT.Common Methods (<>) :: DeriveConfig -> DeriveConfig -> DeriveConfig # sconcat :: NonEmpty DeriveConfig -> DeriveConfig # stimes :: Integral b => b -> DeriveConfig -> DeriveConfig # | |
deriveGADT :: [Name] -> [Name] -> Q [Dec] Source #
Derive the specified classes for a GADT with the given name.
See deriveGADTWith for more details.
deriveGADTWith :: DeriveConfig -> [Name] -> [Name] -> Q [Dec] Source #
Derive the specified classes for a GADT with the given name.
Support the following classes.
MergeableMergeable1Mergeable2Mergeable3EvalSymEvalSym1EvalSym2ExtractSymExtractSym1ExtractSym2SubstSymSubstSym1SubstSym2NFDataNFData1NFData2HashableHashable1Hashable2ShowShow1Show2PPrintPPrint1PPrint2AllSymsAllSyms1AllSyms2EqEq1Eq2OrdOrd1Ord2SymOrdSymOrd1SymOrd2SymEqSymEq1SymEq2UnifiedSymEqUnifiedSymEq1UnifiedSymEq2UnifiedSymOrdUnifiedSymOrd1UnifiedSymOrd2ToSymToSym1ToSym2ToConToCon1ToCon2SerialSerial1Serial2SimpleMergeableSimpleMergeable1SimpleMergeable2
Note that the following type classes cannot be derived for GADTs with existential type variables.
allClasses0 :: [Name] Source #
allClasses01 :: [Name] Source #
All the classes that can be derived for GADT functors.
This includes all the classes in allClasses0 and allClasses1.
allClasses012 :: [Name] Source #
All the classes that can be derived for GADTfunctors.
This includes all the classes in allClasses0, allClasses1,
and allClasses2.
basicClasses0 :: [Name] Source #
noExistentialClasses0 :: [Name] Source #
ordClasses0 :: [Name] Source #
Concrete ordered classes that can be derived for GADTs that
- uses unified evaluation mode, or
- does not contain any symbolic variables.
This includes:
basicClasses1 :: [Name] Source #
Basic classes for GADT functors.
This includes:
noExistentialClasses1 :: [Name] Source #
ordClasses1 :: [Name] Source #
*1 concrete ordered classes that can be derived for GADT functors that
- uses unified evaluation mode, or
- does not contain any symbolic variables.
This includes:
basicClasses2 :: [Name] Source #
Basic classes for GADT functors.
This includes:
noExistentialClasses2 :: [Name] Source #
ordClasses2 :: [Name] Source #
*2 concrete ordered classes that can be derived for GADT functors that
- uses unified evaluation mode, or
- does not contain any symbolic variables.
This includes:
Smart constructors that merges in a monad
makePrefixedSmartCtor Source #
Arguments
| :: String | Prefix for generated wrappers |
| -> Name | The type to generate the wrappers for |
| -> Q [Dec] |
Generate constructor wrappers that wraps the result in a container with
TryMerge.
makePrefixedSmartCtor "mrg" ''Maybe
generates
mrgNothing :: (Mergeable (Maybe a), Applicative m, TryMerge m) => m (Maybe a) mrgNothing = mrgSingle Nothing mrgJust :: (Mergeable (Maybe a), Applicative m, TryMerge m) => a -> m (Maybe a) mrgJust = \x -> mrgSingle (Just x)
Arguments
| :: [String] | Names for generated wrappers |
| -> Name | The type to generate the wrappers for |
| -> Q [Dec] |
Generate constructor wrappers that wraps the result in a container with
TryMerge with provided names.
makeNamedSmartCtor ["mrgTuple2"] ''(,)
generates
mrgTuple2 :: (Mergeable (a, b), Applicative m, TryMerge m) => a -> b -> u (a, b) mrgTuple2 = \v1 v2 -> mrgSingle (v1, v2)
Generate constructor wrappers that wraps the result in a container with
TryMerge.
makeSmartCtor ''Maybe
generates
nothing :: (Mergeable (Maybe a), Applicative m, TryMerge m) => m (Maybe a) nothing = mrgSingle Nothing just :: (Mergeable (Maybe a), Applicative m, TryMerge m) => a -> m (Maybe a) just = \x -> mrgSingle (Just x)
makeSmartCtorWith :: (String -> String) -> Name -> Q [Dec] Source #
Generate constructor wrappers that wraps the result in a container with
TryMerge with provided name transformer.
makeSmartCtorWith (\name -> "mrg" ++ name) ''Maybe
generates
mrgNothing :: (Mergeable (Maybe a), Applicative m, TryMerge m) => m (Maybe a) mrgNothing = mrgSingle Nothing
Smart constructors that are polymorphic in evaluation modes
makePrefixedUnifiedCtor Source #
Arguments
| :: [Name] | |
| -> String | Prefix for generated wrappers |
| -> Name | The type to generate the wrappers for |
| -> Q [Dec] |
Generate smart constructors to create unified values.
For a type T mode a b c with constructors T1, T2, etc., this function
will generate smart constructors with the given prefix, e.g., mkT1, mkT2,
etc.
The generated smart constructors will contruct values of type
GetData mode (T mode a b c).
Arguments
| :: [Name] | |
| -> [String] | Names for generated wrappers |
| -> Name | The type to generate the wrappers for |
| -> Q [Dec] |
Generate smart constructors to create unified values.
For a type T mode a b c with constructors T1, T2, etc., this function
will generate smart constructors with the given names.
The generated smart constructors will contruct values of type
GetData mode (T mode a b c).
Generate smart constructors to create unified values.
For a type T mode a b c with constructors T1, T2, etc., this function
will generate smart constructors with the names decapitalized, e.g.,
t1, t2, etc.
The generated smart constructors will contruct values of type
GetData mode (T mode a b c).
makeUnifiedCtorWith :: [Name] -> (String -> String) -> Name -> Q [Dec] Source #
Generate smart constructors to create unified values with provided name transformer.
For a type T mode a b c with constructors T1, T2, etc., this function
will generate smart constructors with the name transformed, e.g., given the
name transformer (name -> "mk" ++ name), it will generate mkT1, mkT2,
mkT2, etc.
The generated smart constructors will contruct values of type
GetData mode (T mode a b c).