HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulederiving-compat-0.6.8Haskell2010

Data.Deriving.Internal

Template Haskell-related utilities.

Note: this is an internal module, and as such, the API presented here is not guaranteed to be stable, even between minor releases of this library.

  • 8 types
  • 1 class
  • 356 values
datadata Via a b
#

A type-level modifier intended to be used in conjunction with deriveVia. Refer to the documentation for deriveVia for more details.

valuefmapConst :: f b -> (a -> b) -> f a -> f b
#
valuefoldrConst :: b -> (a -> b -> b) -> b -> t a -> b
#
classclass ClassRep a where
#

Methods

Instances8ClassRep, …
  • ClassRep BoundedClassDefined in deriving-compat-0.6.8 · Data.Bounded.Deriving.Internal
  • ClassRep EnumClassDefined in deriving-compat-0.6.8 · Data.Enum.Deriving.Internal
  • ClassRep EqClassDefined in deriving-compat-0.6.8 · Data.Eq.Deriving.Internal
  • ClassRep FunctorClassDefined in deriving-compat-0.6.8 · Data.Functor.Deriving.Internal
  • ClassRep IxClassDefined in deriving-compat-0.6.8 · Data.Ix.Deriving.Internal
  • ClassRep OrdClassDefined in deriving-compat-0.6.8 · Data.Ord.Deriving.Internal
  • ClassRep ReadClassDefined in deriving-compat-0.6.8 · Text.Read.Deriving.Internal
  • ClassRep ShowClassDefined in deriving-compat-0.6.8 · Text.Show.Deriving.Internal
valuebuildTypeInstance
  1. :: ClassRep a
  2. => a

    The typeclass for which an instance should be derived

  3. -> Name

    The type constructor or data family name

  4. -> Cxt

    The datatype context

  5. -> [Type]

    The types to instantiate the instance with

  6. -> DatatypeVariant

    Are we dealing with a data family instance or not

  7. -> Q (Cxt, Type)
#
valuederiveConstraint :: ClassRep a => a -> Type -> (Maybe Pred, [Name])
#

Attempt to derive a constraint on a Type. If successful, return Just the constraint and any kind variable names constrained to *. Otherwise, return Nothing and the empty list.

See Note [Type inference in derived instances] for the heuristics used to come up with constraints.

valuenoConstructorsError :: Q a
#

The given datatype has no constructors, and we don't know what to do with it.

valuederivingKindError :: ClassRep a => a -> Name -> Q b
#

Either the given data type doesn't have enough type variables, or one of the type variables to be eta-reduced cannot realize kind *.

valuecontravarianceError :: Name -> Q a
#

The last type variable appeared in a contravariant position when deriving Functor.

valuenoFunctionsError :: Name -> Q a
#

A constructor has a function argument in a derived Foldable or Traversable instance.

valueetaReductionError :: Type -> Q a
#

One of the last type variables cannot be eta-reduced (see the canEtaReduce function for the criteria it would have to meet).

valueexistentialContextError :: Name -> Q a
#

The data type has an existential constraint which mentions one of the eta-reduced type variables.

valueoutOfPlaceTyVarError :: ClassRep a => a -> Name -> Q b
#

The data type mentions one of the n eta-reduced type variables in a place other than the last nth positions of a data type in a constructor's field.

valuefilterByList :: [Bool] -> [a] -> [a]
#

filterByList takes a list of Bools and a list of some elements and filters out these elements for which the corresponding value in the list of Bools is False. This function does not check whether the lists have equal length.

valuefilterByLists :: [Bool] -> [a] -> [a] -> [a]
#

filterByLists takes a list of Bools and two lists as input, and outputs a new list consisting of elements from the last two input lists. For each Bool in the list, if it is True, then it takes an element from the former list. If it is False, it takes an element from the latter list. The elements taken correspond to the index of the Bool in its list. For example:

filterByLists [True, False, True, False] "abcd" "wxyz" = "axcz"

This function does not check whether the lists have equal length.

valuepartitionByList :: [Bool] -> [a] -> ([a], [a])
#

partitionByList takes a list of Bools and a list of some elements and partitions the list according to the list of Bools. Elements corresponding to True go to the left; elements corresponding to False go to the right. For example, partitionByList [True, False, True] [1,2,3] == ([1,3], [2]) This function does not check whether the lists have equal length.

valuehasKindVarChain :: Int -> Type -> Maybe [Name]
#

hasKindVarChain n kind Checks if kind is of the form k_0 -> k_1 -> ... -> k_(n-1), where k0, k1, ..., and k_(n-1) can be * or kind variables.

valuetyKind :: Type -> Kind
#

If a Type is a SigT, returns its kind signature. Otherwise, return *.

valuethd3 :: (a, b, c) -> c
#
valuecanEtaReduce :: [Type] -> [Type] -> Bool
#

Checks to see if the last types in a data family instance can be safely eta- reduced (i.e., dropped), given the other types. This checks for three conditions:

  1. All of the dropped types are type variables

  2. All of the dropped types are distinct

  3. None of the remaining types mention any of the dropped types

valueconTToName :: Type -> Name
#

Extract the Name from a type constructor. If the argument Type is not a type variable, throw an error.

Extract Just the Name from a type variable. If the argument Type is not a type variable, return Nothing.

valuevarTToName :: Type -> Name
#

Extract the Name from a type variable. If the argument Type is not a type variable, throw an error.

valueunSigT :: Type -> Type
#

Peel off a kind signature from a Type (if it has one).

valueisInTypeFamilyApp :: [Name] -> Type -> [Type] -> Q Bool
#

Detect if a Name in a list of provided Names occurs as an argument to some type family. This makes an effort to exclude oversaturated arguments to type families. For instance, if one declared the following type family:

type family F a :: Type -> Type

Then in the type F a b, we would consider a to be an argument to F, but not b.

valueallDistinct :: Ord a => [a] -> Bool
#

Are all of the items in a list (which have an ordering) distinct?

This uses Set (as opposed to nub) for better asymptotic time complexity.

valueunapplyTy :: Type -> (Type, [Type])
#

Split an applied type into its individual components. For example, this:

Either Int Char

would split to this:

[Either, Int, Char]
valueuncurryTy :: Type -> (Cxt, [Type])
#

Split a type signature by the arrows on its spine. For example, this:

forall a b. (a ~ b) => (a -> b) -> Char -> ()

would split to this:

(a ~ b, [a -> b, Char, ()])