grisette-0.8.0.0: Symbolic evaluation as a library
Copyright(c) Sirui Lu 2024
LicenseBSD-3-Clause (see the LICENSE file)
Maintainersiruilu@cs.washington.edu
StabilityExperimental
PortabilityGHC only
Safe HaskellSafe-Inferred
LanguageHaskell2010

Grisette.Internal.TH.DeriveTypeParamHandler

Description

 
Synopsis

Documentation

class DeriveTypeParamHandler handler where Source #

A derive type param handler handles type parameters and provides constraints or instantiations for them.

The first argument is the number of types that are zipped together. For most classes, this is 1, but for some classes, like ToCon, this is 2.

The second argument is the handler itself.

The third argument is a list of type parameters and their constraints. Each entry in the list corresponds to a type parameter of the datatype. The first element in the pair is a list of zipped type parameters with possibly concrete types. For example, if we are deriving ToCon for Either, the argument will be:

[([(e0, Nothing), (e1, Nothing)], Nothing),
 ([(a0, Nothing), (a1, Nothing)], Nothing)]

We can see that the type parameters for the concrete and symbolic Either types are zipped together: the first element of the list are for the error types, and the second element of the list are for the value types.

The handler may concretize some types, or add constraints based on the type parameters.

Methods

handleTypeParams :: Int -> handler -> [([(TyVarBndrUnit, Maybe Type)], Maybe [Pred])] -> Q [([(TyVarBndrUnit, Maybe Type)], Maybe [Pred])] Source #

handleBody :: handler -> [[Type]] -> Q [Pred] Source #

Instances

Instances details
DeriveTypeParamHandler IsFPBits Source # 
Instance details

Defined in Grisette.Internal.TH.DeriveTypeParamHandler

DeriveTypeParamHandler NatShouldBePositive Source # 
Instance details

Defined in Grisette.Internal.TH.DeriveTypeParamHandler

DeriveTypeParamHandler PrimaryConstraint Source # 
Instance details

Defined in Grisette.Internal.TH.DeriveTypeParamHandler

DeriveTypeParamHandler SomeDeriveTypeParamHandler Source # 
Instance details

Defined in Grisette.Internal.TH.DeriveTypeParamHandler

DeriveTypeParamHandler PrimaryUnifiedConstraint Source # 
Instance details

Defined in Grisette.Internal.TH.DeriveUnifiedInterface

DeriveTypeParamHandler TypeableMode Source # 
Instance details

Defined in Grisette.Internal.TH.DeriveUnifiedInterface

data NatShouldBePositive Source #

Ensures that type parameters with the kind Nat are known and positive.

Constructors

NatShouldBePositive 

data IsFPBits Source #

Ensures that the type parameters are valid for floating point operations.

Constructors

IsFPBits 

Fields

data PrimaryConstraint Source #

Adds a primary constraint to the type parameters. It applies the class to each type parameter that are zipped into a list, with the desired kinds.

For example, if we are deriving ToCon for Either, and the input to this handler is as follows:

[([(e0, Nothing), (e1, Nothing)], Nothing),
 ([(a0, Nothing), (a1, Nothing)], Nothing)]

Then this will generate constraints for the type parameters of Either:

[([(e0, Nothing), (e1, Nothing)], Just [ToCon e0 e1]),
 ([(a0, Nothing), (a1, Nothing)], Just [ToCon a0 a1])]

Type parameters that are already handled by other handlers can be ignored.