th-utilities-0.2.5.2: Collection of useful functions for use with Template Haskell

Safe Haskell | None
Language | Haskell2010

TH.ReifySimple

Contents

- Reifying simplified type info
- Reifying simplified info for specific declaration varieties
  - Datatype info
  - Data constructor info
  - Data family info
  - Type family info
- Other utilities

Description

Utilities for reifying simplified datatype info. It omits details that aren't usually relevant to generating instances that work with the datatype. This makes it easier to use TH to derive instances.

The "Simple" in the module name refers to the simplicity of the datatypes, not the module itself, which exports quite a few things which are useful in some circumstance or another. I anticipate that the most common uses of this will be the following APIs:

- Getting info about a `data` or `newtype` declaration, via `DataType`, `reifyDataType`, and `DataCon`. This is useful for writing something which generates declarations based on a datatype, one of the most common uses of Template Haskell.
- Getting nicely structured info about a named type. See `TypeInfo` and `reifyType`. This does not yet support reifying typeclasses, primitive type constructors, or type variables (`TyVarI`).

Currently, this module supports reifying simplified versions of the following `Info` constructors:

- `TyConI` with `DataD` and `NewtypeD` (becomes a `DataType` value)
- `FamilyI` becomes a `DataFamily` or `TypeFamily` value.
- `DataConI` becomes a `DataCon` value.

In the future it will hopefully also have support for the remaining `Info` constructors, `ClassI`, `ClassOpI`, `PrimTyConI`, `VarI`, and `TyVarI`.

Synopsis

- data TypeInfo
- reifyType :: Name -> Q TypeInfo
- infoToType :: Info -> Q (Maybe TypeInfo)
- reifyTypeNoDataKinds :: Name -> Q (Maybe TypeInfo)
- infoToTypeNoDataKinds :: Info -> Maybe TypeInfo
- data DataType = DataType {
  - dtName :: Name
  - dtTvs :: [Name]
  - dtCxt :: Cxt
  - dtCons :: [DataCon]
  }
- reifyDataType :: Name -> Q DataType
- infoToDataType :: Info -> Maybe DataType
- data DataCon = DataCon {
  - dcName :: Name
  - dcTvs :: [Name]
  - dcCxt :: Cxt
  - dcFields :: [(Maybe Name, Type)]
  }
- reifyDataCon :: Name -> Q DataCon
- infoToDataCon :: Info -> Maybe DataCon
- typeToDataCon :: Name -> Type -> DataCon
- data DataFamily = DataFamily {
  - dfName :: Name
  - dfTvs :: [Name]
  - dfInsts :: [DataInst]
  }
- data DataInst = DataInst {
  - diName :: Name
  - diCxt :: Cxt
  - diParams :: [Type]
  - diCons :: [DataCon]
  }
- reifyDataFamily :: Name -> Q DataFamily
- infoToDataFamily :: Info -> Maybe DataFamily
- data TypeFamily = TypeFamily {
  - tfName :: Name
  - tfTvs :: [Name]
  - tfInsts :: [TypeInst]
  }
- data TypeInst = TypeInst {
  - tiName :: Name
  - tiParams :: [Type]
  - tiType :: Type
  }
- reifyTypeFamily :: Name -> Q TypeFamily
- infoToTypeFamily :: Info -> Maybe TypeFamily
- conToDataCons :: Con -> [DataCon]
- reifyDataTypeSubstituted :: Type -> Q DataType

# Reifying simplified type info

data TypeInfo Source #

reifyType :: Name -> Q TypeInfo Source #

Reifies a `Name` as a `TypeInfo`, and calls `fail` if this doesn't work. Use `reify` with `infoToType` if you want to handle the failure case more gracefully.

This does not yet support reifying typeclasses, primitive type constructors, or type variables (`TyVarI`).

infoToType :: Info -> Q (Maybe TypeInfo) Source #

Convert an `Info` into a `TypeInfo` if possible, and otherwise yield `Nothing`. Needs to run in `Q` so that

reifyTypeNoDataKinds :: Name -> Q (Maybe TypeInfo) Source #

Reifies type info, but instead of yielding a `LiftedDataConInfo`, will instead yield `Nothing`.

infoToTypeNoDataKinds :: Info -> Maybe TypeInfo Source #

Convert an 'Info into a `TypeInfo` if possible. If it's a data constructor, instead of yielding `LiftedDataConInfo`, it will instead yield `Nothing`.

# Reifying simplified info for specific declaration varieties

## Datatype info

data DataType Source #

Simplified info about a `DataD`. Omits deriving, strictness, kind info, and whether it's `data` or `newtype`.

Constructors

DataType |

Fields

- dtName :: Name
- dtTvs :: [Name]
- dtCxt :: Cxt
- dtCons :: [DataCon]

#### Instances

Instances details

Data DataType Source # |

Instance details

Defined in TH.ReifySimple

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DataType -> c DataType Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DataType Source #

toConstr :: DataType -> Constr Source #

dataTypeOf :: DataType -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DataType) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataType) Source #

gmapT :: (forall b. Data b => b -> b) -> DataType -> DataType Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DataType -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DataType -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> DataType -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> DataType -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DataType -> m DataType Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DataType -> m DataType Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DataType -> m DataType Source #

Generic DataType Source # |

Instance details

Defined in TH.ReifySimple

Associated Types

type Rep DataType |

Instance details

Defined in TH.ReifySimple

type Rep DataType = D1 ('MetaData "DataType" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "DataType" 'PrefixI 'True) ((S1 ('MetaSel ('Just "dtName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: S1 ('MetaSel ('Just "dtTvs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name])) :*: (S1 ('MetaSel ('Just "dtCxt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Cxt) :*: S1 ('MetaSel ('Just "dtCons") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [DataCon]))))

Methods

from :: DataType -> Rep DataType x Source #

to :: Rep DataType x -> DataType Source #

Show DataType Source # |
Instance details Defined in TH.ReifySimple Methods showsPrec :: Int -> DataType -> ShowS Source # show :: DataType -> String Source # showList :: [DataType] -> ShowS Source #
Eq DataType Source # |
Instance details Defined in TH.ReifySimple Methods (==) :: DataType -> DataType -> Bool Source # (/=) :: DataType -> DataType -> Bool Source #
Ord DataType Source # |
Instance details Defined in TH.ReifySimple Methods compare :: DataType -> DataType -> Ordering Source # (<) :: DataType -> DataType -> Bool Source # (<=) :: DataType -> DataType -> Bool Source # (>) :: DataType -> DataType -> Bool Source # (>=) :: DataType -> DataType -> Bool Source # max :: DataType -> DataType -> DataType Source # min :: DataType -> DataType -> DataType Source #
type Rep DataType Source # |

Instance details

Defined in TH.ReifySimple

type Rep DataType = D1 ('MetaData "DataType" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "DataType" 'PrefixI 'True) ((S1 ('MetaSel ('Just "dtName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: S1 ('MetaSel ('Just "dtTvs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name])) :*: (S1 ('MetaSel ('Just "dtCxt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Cxt) :*: S1 ('MetaSel ('Just "dtCons") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [DataCon]))))

reifyDataType :: Name -> Q DataType Source #

Reify the given data or newtype declaration, and yields its `DataType` representation.

infoToDataType :: Info -> Maybe DataType Source #

## Data constructor info

data DataCon Source #

Simplified info about a `Con`. Omits deriving, strictness, and kind info. This is much nicer than consuming `Con` directly, because it unifies all the constructors into one.

Constructors

DataCon |

Fields

- dcName :: Name
- dcTvs :: [Name]
- dcCxt :: Cxt
- dcFields :: [(Maybe Name, Type)]

#### Instances

Instances details

Data DataCon Source # |

Instance details

Defined in TH.ReifySimple

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DataCon -> c DataCon Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DataCon Source #

toConstr :: DataCon -> Constr Source #

dataTypeOf :: DataCon -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DataCon) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataCon) Source #

gmapT :: (forall b. Data b => b -> b) -> DataCon -> DataCon Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DataCon -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DataCon -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> DataCon -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> DataCon -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DataCon -> m DataCon Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DataCon -> m DataCon Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DataCon -> m DataCon Source #

Generic DataCon Source # |

Instance details

Defined in TH.ReifySimple

Associated Types

type Rep DataCon |

Instance details

Defined in TH.ReifySimple

type Rep DataCon = D1 ('MetaData "DataCon" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "DataCon" 'PrefixI 'True) ((S1 ('MetaSel ('Just "dcName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: S1 ('MetaSel ('Just "dcTvs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name])) :*: (S1 ('MetaSel ('Just "dcCxt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Cxt) :*: S1 ('MetaSel ('Just "dcFields") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(Maybe Name, Type)]))))

Methods

from :: DataCon -> Rep DataCon x Source #

to :: Rep DataCon x -> DataCon Source #

Show DataCon Source # |
Instance details Defined in TH.ReifySimple Methods showsPrec :: Int -> DataCon -> ShowS Source # show :: DataCon -> String Source # showList :: [DataCon] -> ShowS Source #
Eq DataCon Source # |
Instance details Defined in TH.ReifySimple Methods (==) :: DataCon -> DataCon -> Bool Source # (/=) :: DataCon -> DataCon -> Bool Source #
Ord DataCon Source # |
Instance details Defined in TH.ReifySimple Methods compare :: DataCon -> DataCon -> Ordering Source # (<) :: DataCon -> DataCon -> Bool Source # (<=) :: DataCon -> DataCon -> Bool Source # (>) :: DataCon -> DataCon -> Bool Source # (>=) :: DataCon -> DataCon -> Bool Source # max :: DataCon -> DataCon -> DataCon Source # min :: DataCon -> DataCon -> DataCon Source #
type Rep DataCon Source # |

Instance details

Defined in TH.ReifySimple

type Rep DataCon = D1 ('MetaData "DataCon" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "DataCon" 'PrefixI 'True) ((S1 ('MetaSel ('Just "dcName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: S1 ('MetaSel ('Just "dcTvs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name])) :*: (S1 ('MetaSel ('Just "dcCxt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Cxt) :*: S1 ('MetaSel ('Just "dcFields") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(Maybe Name, Type)]))))

reifyDataCon :: Name -> Q DataCon Source #

Reify the given data constructor.

infoToDataCon :: Info -> Maybe DataCon Source #

typeToDataCon :: Name -> Type -> DataCon Source #

Creates a `DataCon` given the `Name` and `Type` of a data-constructor. Note that the result the function type is *not* checked to match the provided `Name`.

## Data family info

data DataFamily Source #

Simplified info about a data family. Omits deriving, strictness, and kind info.

Constructors

DataFamily |

Fields

- dfName :: Name
- dfTvs :: [Name]
- dfInsts :: [DataInst]

#### Instances

Instances details

Data DataFamily Source # |

Instance details

Defined in TH.ReifySimple

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DataFamily -> c DataFamily Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DataFamily Source #

toConstr :: DataFamily -> Constr Source #

dataTypeOf :: DataFamily -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DataFamily) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataFamily) Source #

gmapT :: (forall b. Data b => b -> b) -> DataFamily -> DataFamily Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DataFamily -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DataFamily -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> DataFamily -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> DataFamily -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DataFamily -> m DataFamily Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DataFamily -> m DataFamily Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DataFamily -> m DataFamily Source #

Generic DataFamily Source # |

Instance details

Defined in TH.ReifySimple

Associated Types

type Rep DataFamily |

Instance details

Defined in TH.ReifySimple

type Rep DataFamily = D1 ('MetaData "DataFamily" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "DataFamily" 'PrefixI 'True) (S1 ('MetaSel ('Just "dfName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: (S1 ('MetaSel ('Just "dfTvs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name]) :*: S1 ('MetaSel ('Just "dfInsts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [DataInst]))))

Methods

from :: DataFamily -> Rep DataFamily x Source #

to :: Rep DataFamily x -> DataFamily Source #

Show DataFamily Source # |
Instance details Defined in TH.ReifySimple Methods showsPrec :: Int -> DataFamily -> ShowS Source # show :: DataFamily -> String Source # showList :: [DataFamily] -> ShowS Source #
Eq DataFamily Source # |
Instance details Defined in TH.ReifySimple Methods (==) :: DataFamily -> DataFamily -> Bool Source # (/=) :: DataFamily -> DataFamily -> Bool Source #
Ord DataFamily Source # |

Instance details

Defined in TH.ReifySimple

Methods

compare :: DataFamily -> DataFamily -> Ordering Source #

(<) :: DataFamily -> DataFamily -> Bool Source #

(<=) :: DataFamily -> DataFamily -> Bool Source #

(>) :: DataFamily -> DataFamily -> Bool Source #

(>=) :: DataFamily -> DataFamily -> Bool Source #

max :: DataFamily -> DataFamily -> DataFamily Source #

min :: DataFamily -> DataFamily -> DataFamily Source #

type Rep DataFamily Source # |

Instance details

Defined in TH.ReifySimple

type Rep DataFamily = D1 ('MetaData "DataFamily" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "DataFamily" 'PrefixI 'True) (S1 ('MetaSel ('Just "dfName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: (S1 ('MetaSel ('Just "dfTvs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name]) :*: S1 ('MetaSel ('Just "dfInsts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [DataInst]))))

data DataInst Source #

Simplified info about a data family instance. Omits deriving, strictness, and kind info.

Constructors

DataInst |

Fields

- diName :: Name
- diCxt :: Cxt
- diParams :: [Type]
- diCons :: [DataCon]

#### Instances

Instances details

Data DataInst Source # |

Instance details

Defined in TH.ReifySimple

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DataInst -> c DataInst Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DataInst Source #

toConstr :: DataInst -> Constr Source #

dataTypeOf :: DataInst -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DataInst) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataInst) Source #

gmapT :: (forall b. Data b => b -> b) -> DataInst -> DataInst Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DataInst -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DataInst -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> DataInst -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> DataInst -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DataInst -> m DataInst Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DataInst -> m DataInst Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DataInst -> m DataInst Source #

Generic DataInst Source # |

Instance details

Defined in TH.ReifySimple

Associated Types

type Rep DataInst |

Instance details

Defined in TH.ReifySimple

type Rep DataInst = D1 ('MetaData "DataInst" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "DataInst" 'PrefixI 'True) ((S1 ('MetaSel ('Just "diName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: S1 ('MetaSel ('Just "diCxt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Cxt)) :*: (S1 ('MetaSel ('Just "diParams") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Type]) :*: S1 ('MetaSel ('Just "diCons") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [DataCon]))))

Methods

from :: DataInst -> Rep DataInst x Source #

to :: Rep DataInst x -> DataInst Source #

Show DataInst Source # |
Instance details Defined in TH.ReifySimple Methods showsPrec :: Int -> DataInst -> ShowS Source # show :: DataInst -> String Source # showList :: [DataInst] -> ShowS Source #
Eq DataInst Source # |
Instance details Defined in TH.ReifySimple Methods (==) :: DataInst -> DataInst -> Bool Source # (/=) :: DataInst -> DataInst -> Bool Source #
Ord DataInst Source # |
Instance details Defined in TH.ReifySimple Methods compare :: DataInst -> DataInst -> Ordering Source # (<) :: DataInst -> DataInst -> Bool Source # (<=) :: DataInst -> DataInst -> Bool Source # (>) :: DataInst -> DataInst -> Bool Source # (>=) :: DataInst -> DataInst -> Bool Source # max :: DataInst -> DataInst -> DataInst Source # min :: DataInst -> DataInst -> DataInst Source #
type Rep DataInst Source # |

Instance details

Defined in TH.ReifySimple

type Rep DataInst = D1 ('MetaData "DataInst" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "DataInst" 'PrefixI 'True) ((S1 ('MetaSel ('Just "diName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: S1 ('MetaSel ('Just "diCxt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Cxt)) :*: (S1 ('MetaSel ('Just "diParams") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Type]) :*: S1 ('MetaSel ('Just "diCons") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [DataCon]))))

reifyDataFamily :: Name -> Q DataFamily Source #

Reify the given data family, and yield its `DataFamily` representation.

infoToDataFamily :: Info -> Maybe DataFamily Source #

## Type family info

data TypeFamily Source #

Simplified info about a type family. Omits kind info and injectivity info.

Constructors

TypeFamily |

Fields

- tfName :: Name
- tfTvs :: [Name]
- tfInsts :: [TypeInst]

#### Instances

Instances details

Data TypeFamily Source # |

Instance details

Defined in TH.ReifySimple

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeFamily -> c TypeFamily Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeFamily Source #

toConstr :: TypeFamily -> Constr Source #

dataTypeOf :: TypeFamily -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TypeFamily) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeFamily) Source #

gmapT :: (forall b. Data b => b -> b) -> TypeFamily -> TypeFamily Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeFamily -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeFamily -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TypeFamily -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeFamily -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeFamily -> m TypeFamily Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeFamily -> m TypeFamily Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeFamily -> m TypeFamily Source #

Generic TypeFamily Source # |

Instance details

Defined in TH.ReifySimple

Associated Types

type Rep TypeFamily |

Instance details

Defined in TH.ReifySimple

type Rep TypeFamily = D1 ('MetaData "TypeFamily" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "TypeFamily" 'PrefixI 'True) (S1 ('MetaSel ('Just "tfName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: (S1 ('MetaSel ('Just "tfTvs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name]) :*: S1 ('MetaSel ('Just "tfInsts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TypeInst]))))

Methods

from :: TypeFamily -> Rep TypeFamily x Source #

to :: Rep TypeFamily x -> TypeFamily Source #

Show TypeFamily Source # |
Instance details Defined in TH.ReifySimple Methods showsPrec :: Int -> TypeFamily -> ShowS Source # show :: TypeFamily -> String Source # showList :: [TypeFamily] -> ShowS Source #
Eq TypeFamily Source # |
Instance details Defined in TH.ReifySimple Methods (==) :: TypeFamily -> TypeFamily -> Bool Source # (/=) :: TypeFamily -> TypeFamily -> Bool Source #
Ord TypeFamily Source # |

Instance details

Defined in TH.ReifySimple

Methods

compare :: TypeFamily -> TypeFamily -> Ordering Source #

(<) :: TypeFamily -> TypeFamily -> Bool Source #

(<=) :: TypeFamily -> TypeFamily -> Bool Source #

(>) :: TypeFamily -> TypeFamily -> Bool Source #

(>=) :: TypeFamily -> TypeFamily -> Bool Source #

max :: TypeFamily -> TypeFamily -> TypeFamily Source #

min :: TypeFamily -> TypeFamily -> TypeFamily Source #

type Rep TypeFamily Source # |

Instance details

Defined in TH.ReifySimple

type Rep TypeFamily = D1 ('MetaData "TypeFamily" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "TypeFamily" 'PrefixI 'True) (S1 ('MetaSel ('Just "tfName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: (S1 ('MetaSel ('Just "tfTvs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name]) :*: S1 ('MetaSel ('Just "tfInsts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TypeInst]))))

data TypeInst Source #

Simplified info about a type family instance. Omits nothing.

Constructors

TypeInst |

Fields

- tiName :: Name
- tiParams :: [Type]
- tiType :: Type

#### Instances

Instances details

Data TypeInst Source # |

Instance details

Defined in TH.ReifySimple

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeInst -> c TypeInst Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeInst Source #

toConstr :: TypeInst -> Constr Source #

dataTypeOf :: TypeInst -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TypeInst) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeInst) Source #

gmapT :: (forall b. Data b => b -> b) -> TypeInst -> TypeInst Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeInst -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeInst -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TypeInst -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeInst -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeInst -> m TypeInst Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeInst -> m TypeInst Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeInst -> m TypeInst Source #

Generic TypeInst Source # |

Instance details

Defined in TH.ReifySimple

Associated Types

type Rep TypeInst |

Instance details

Defined in TH.ReifySimple

type Rep TypeInst = D1 ('MetaData "TypeInst" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "TypeInst" 'PrefixI 'True) (S1 ('MetaSel ('Just "tiName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: (S1 ('MetaSel ('Just "tiParams") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Type]) :*: S1 ('MetaSel ('Just "tiType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Type))))

Methods

from :: TypeInst -> Rep TypeInst x Source #

to :: Rep TypeInst x -> TypeInst Source #

Show TypeInst Source # |
Instance details Defined in TH.ReifySimple Methods showsPrec :: Int -> TypeInst -> ShowS Source # show :: TypeInst -> String Source # showList :: [TypeInst] -> ShowS Source #
Eq TypeInst Source # |
Instance details Defined in TH.ReifySimple Methods (==) :: TypeInst -> TypeInst -> Bool Source # (/=) :: TypeInst -> TypeInst -> Bool Source #
Ord TypeInst Source # |
Instance details Defined in TH.ReifySimple Methods compare :: TypeInst -> TypeInst -> Ordering Source # (<) :: TypeInst -> TypeInst -> Bool Source # (<=) :: TypeInst -> TypeInst -> Bool Source # (>) :: TypeInst -> TypeInst -> Bool Source # (>=) :: TypeInst -> TypeInst -> Bool Source # max :: TypeInst -> TypeInst -> TypeInst Source # min :: TypeInst -> TypeInst -> TypeInst Source #
type Rep TypeInst Source # |

Instance details

Defined in TH.ReifySimple

type Rep TypeInst = D1 ('MetaData "TypeInst" "TH.ReifySimple" "th-utilities-0.2.5.2-BFyIsepSr1HAlsJqopPWuT" 'False) (C1 ('MetaCons "TypeInst" 'PrefixI 'True) (S1 ('MetaSel ('Just "tiName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: (S1 ('MetaSel ('Just "tiParams") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Type]) :*: S1 ('MetaSel ('Just "tiType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Type))))

reifyTypeFamily :: Name -> Q TypeFamily Source #

Reify the given type family instance declaration, and yields its `TypeInst` representation.

infoToTypeFamily :: Info -> Maybe TypeFamily Source #

# Other utilities

conToDataCons :: Con -> [DataCon] Source #

Convert a `Con` to a list of `DataCon`. The result is a list because `GadtC` and `RecGadtC` can define multiple constructors.

reifyDataTypeSubstituted :: Type -> Q DataType Source #

Like `reifyDataType`, but takes a `Type` instead of just the `Name` of the datatype. It expects a normal datatype argument (see `typeToNamedCon`).