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
- Packagederiving-compat-0.6.8
- Exports365
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceInternal.hs
A type-level modifier intended to be used in conjunction with deriveVia.
Refer to the documentation for deriveVia for more details.
Whether a type is not of kind *, is of kind *, or is a kind variable.
Constructors
Instances1Eq
Eq StarKindStatusDefined in deriving-compat-0.6.8 · Data.Deriving.Internal
Does a Type have kind * or k (for some kind variable k)?
Returns Just the kind variable Name of a StarKindStatus if it exists. Otherwise, returns Nothing.
Concat together all of the StarKindStatuses that are IsKindVar and extract the kind variables' Names out.
Methods
arity :: a -> IntallowExQuant :: a -> BoolfullClassName :: a -> NameclassConstraint :: a -> Int -> Maybe Name
Instances8ClassRep, …
ClassRep BoundedClassDefined in deriving-compat-0.6.8 · Data.Bounded.Deriving.InternalClassRep EnumClassDefined in deriving-compat-0.6.8 · Data.Enum.Deriving.InternalClassRep EqClassDefined in deriving-compat-0.6.8 · Data.Eq.Deriving.InternalClassRep FunctorClassDefined in deriving-compat-0.6.8 · Data.Functor.Deriving.InternalClassRep IxClassDefined in deriving-compat-0.6.8 · Data.Ix.Deriving.InternalClassRep OrdClassDefined in deriving-compat-0.6.8 · Data.Ord.Deriving.InternalClassRep ReadClassDefined in deriving-compat-0.6.8 · Text.Read.Deriving.InternalClassRep ShowClassDefined in deriving-compat-0.6.8 · Text.Show.Deriving.Internal
buildTypeInstance 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.
The given datatype has no constructors, and we don't know what to do with it.
Either the given data type doesn't have enough type variables, or one of the type variables to be eta-reduced cannot realize kind *.
The last type variable appeared in a contravariant position when deriving Functor.
A constructor has a function argument in a derived Foldable or Traversable instance.
One of the last type variables cannot be eta-reduced (see the canEtaReduce function for the criteria it would have to meet).
The data type has a DatatypeContext which mentions one of the eta-reduced type variables.
The data type has an existential constraint which mentions one of the eta-reduced type variables.
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.
A mapping of type variable Names to their auxiliary function Names.
Constructors
OneName :: Name -> OneOrTwoNames OneTwoNames :: Name -> Name -> OneOrTwoNames Two
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.
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.
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.
Returns True if a Type has kind *.
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.
If a Type is a SigT, returns its kind signature. Otherwise, return *.
Returns the number of fields for the constructor.
Returns True if it's a datatype with exactly one, non-existential constructor.
Returns True if it's a datatype with one or more nullary, non-GADT constructors.
Returns False if we're dealing with existential quantification or GADTs.
Generate a list of fresh names with a common prefix, and numbered suffixes.
Extracts the kind from a TyVarBndr.
Convert a TyVarBndr to a Type.
Applies a typeclass constraint to a type.
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:
All of the dropped types are type variables
All of the dropped types are distinct
None of the remaining types mention any of the dropped types
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.
Extract the Name from a type variable. If the argument Type is not a type variable, throw an error.
Peel off a kind signature from a Type (if it has one).
Is the given type a variable?
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.
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.
Does the given type mention any of the Names in the list?
Construct a type via curried application.
Fully applies a type constructor to its type variables.
Split an applied type into its individual components. For example, this:
Either Int Char
would split to this:
[Either, Int, Char]
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, ()])
Like uncurryType, except on a kind level.
Checks if a Name represents a tuple type constructor (other than ())
Checks if a String represents a tuple (other than ())
Checks if a String names a valid Haskell infix data constructor (i.e., does it begin with a colon?).