Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Data types for types
Synopsis
- type SourceType = Type SourceAnn
- type SourceConstraint = Constraint SourceAnn
- newtype SkolemScope = SkolemScope {}
- data WildcardData
- data TypeVarVisibility
- typeVarVisibilityPrefix :: TypeVarVisibility -> Text
- data Type a
- = TUnknown a Int
- | TypeVar a Text
- | TypeLevelString a PSString
- | TypeLevelInt a Integer
- | TypeWildcard a WildcardData
- | TypeConstructor a (Qualified (ProperName 'TypeName))
- | TypeOp a (Qualified (OpName 'TypeOpName))
- | TypeApp a (Type a) (Type a)
- | KindApp a (Type a) (Type a)
- | ForAll a TypeVarVisibility Text (Maybe (Type a)) (Type a) (Maybe SkolemScope)
- | ConstrainedType a (Constraint a) (Type a)
- | Skolem a Text (Maybe (Type a)) Int SkolemScope
- | REmpty a
- | RCons a Label (Type a) (Type a)
- | KindedType a (Type a) (Type a)
- | BinaryNoParensType a (Type a) (Type a) (Type a)
- | ParensInType a (Type a)
- srcTUnknown :: Int -> SourceType
- srcTypeVar :: Text -> SourceType
- srcTypeLevelString :: PSString -> SourceType
- srcTypeLevelInt :: Integer -> SourceType
- srcTypeWildcard :: SourceType
- srcTypeConstructor :: Qualified (ProperName 'TypeName) -> SourceType
- srcTypeApp :: SourceType -> SourceType -> SourceType
- srcKindApp :: SourceType -> SourceType -> SourceType
- srcForAll :: TypeVarVisibility -> Text -> Maybe SourceType -> SourceType -> Maybe SkolemScope -> SourceType
- srcConstrainedType :: SourceConstraint -> SourceType -> SourceType
- srcREmpty :: SourceType
- srcRCons :: Label -> SourceType -> SourceType -> SourceType
- srcKindedType :: SourceType -> SourceType -> SourceType
- pattern REmptyKinded :: forall a. a -> Maybe (Type a) -> Type a
- toREmptyKinded :: forall a. Type a -> Maybe (a, Maybe (Type a))
- isREmpty :: forall a. Type a -> Bool
- data ConstraintData = PartialConstraintData [[Text]] Bool
- data Constraint a = Constraint {
- constraintAnn :: a
- constraintClass :: Qualified (ProperName 'ClassName)
- constraintKindArgs :: [Type a]
- constraintArgs :: [Type a]
- constraintData :: Maybe ConstraintData
- srcConstraint :: Qualified (ProperName 'ClassName) -> [SourceType] -> [SourceType] -> Maybe ConstraintData -> SourceConstraint
- mapConstraintArgs :: ([Type a] -> [Type a]) -> Constraint a -> Constraint a
- overConstraintArgs :: Functor f => ([Type a] -> f [Type a]) -> Constraint a -> f (Constraint a)
- mapConstraintArgsAll :: ([Type a] -> [Type a]) -> Constraint a -> Constraint a
- overConstraintArgsAll :: Applicative f => ([Type a] -> f [Type a]) -> Constraint a -> f (Constraint a)
- constraintDataToJSON :: ConstraintData -> Value
- constraintToJSON :: (a -> Value) -> Constraint a -> Value
- typeVarVisToJSON :: TypeVarVisibility -> Value
- typeToJSON :: forall a. (a -> Value) -> Type a -> Value
- constraintDataFromJSON :: Value -> Parser ConstraintData
- constraintFromJSON :: forall a. Parser a -> (Value -> Parser a) -> Value -> Parser (Constraint a)
- typeVarVisFromJSON :: Value -> Parser TypeVarVisibility
- typeFromJSON :: forall a. Parser a -> (Value -> Parser a) -> Value -> Parser (Type a)
- data RowListItem a = RowListItem {
- rowListAnn :: a
- rowListLabel :: Label
- rowListType :: Type a
- srcRowListItem :: Label -> SourceType -> RowListItem SourceAnn
- rowToList :: Type a -> ([RowListItem a], Type a)
- rowToSortedList :: Type a -> ([RowListItem a], Type a)
- rowFromList :: ([RowListItem a], Type a) -> Type a
- alignRowsWith :: (Label -> Type a -> Type a -> r) -> Type a -> Type a -> ([r], (([RowListItem a], Type a), ([RowListItem a], Type a)))
- isMonoType :: Type a -> Bool
- mkForAll :: [(a, (Text, Maybe (Type a)))] -> Type a -> Type a
- replaceTypeVars :: Text -> Type a -> Type a -> Type a
- replaceAllTypeVars :: [(Text, Type a)] -> Type a -> Type a
- addVisibility :: [(Text, TypeVarVisibility)] -> Type a -> Type a
- usedTypeVariables :: Type a -> [Text]
- freeTypeVariables :: Type a -> [Text]
- completeBinderList :: Type a -> Maybe ([(a, (Text, Type a))], Type a)
- quantify :: Type a -> Type a
- moveQuantifiersToFront :: Type a -> Type a
- containsForAll :: Type a -> Bool
- unknowns :: Type a -> IntSet
- containsUnknowns :: Type a -> Bool
- eraseKindApps :: Type a -> Type a
- eraseForAllKindAnnotations :: Type a -> Type a
- unapplyTypes :: Type a -> (Type a, [Type a], [Type a])
- unapplyConstraints :: Type a -> ([Constraint a], Type a)
- srcInstanceType :: SourceSpan -> [(Text, SourceType)] -> Qualified (ProperName 'ClassName) -> [SourceType] -> SourceType
- everywhereOnTypes :: (Type a -> Type a) -> Type a -> Type a
- everywhereOnTypesM :: Monad m => (Type a -> m (Type a)) -> Type a -> m (Type a)
- everywhereOnTypesTopDownM :: Monad m => (Type a -> m (Type a)) -> Type a -> m (Type a)
- everythingOnTypes :: (r -> r -> r) -> (Type a -> r) -> Type a -> r
- everythingWithContextOnTypes :: s -> r -> (r -> r -> r) -> (s -> Type a -> (s, r)) -> Type a -> r
- annForType :: Lens' (Type a) a
- getAnnForType :: Type a -> a
- setAnnForType :: a -> Type a -> Type a
- eqType :: Type a -> Type b -> Bool
- eqMaybeType :: Maybe (Type a) -> Maybe (Type b) -> Bool
- compareType :: Type a -> Type b -> Ordering
- compareMaybeType :: Maybe (Type a) -> Maybe (Type b) -> Ordering
- eqConstraint :: Constraint a -> Constraint b -> Bool
- compareConstraint :: Constraint a -> Constraint b -> Ordering
Documentation
type SourceType = Type SourceAnn Source #
type SourceConstraint = Constraint SourceAnn Source #
newtype SkolemScope Source #
An identifier for the scope of a skolem variable
Instances
data WildcardData Source #
Describes how a TypeWildcard should be presented to the user during type checking: holes (?foo) are always emitted as errors, whereas unnamed wildcards (_) default to warnings, but are ignored entirely if they are contained by a binding with a complete (wildcard-free) type signature.
Instances
data TypeVarVisibility Source #
Instances
The type of types
TUnknown a Int | A unification variable of type Type |
TypeVar a Text | A named type variable |
TypeLevelString a PSString | A type-level string |
TypeLevelInt a Integer | A type-level natural |
TypeWildcard a WildcardData | A type wildcard, as would appear in a partial type synonym |
TypeConstructor a (Qualified (ProperName 'TypeName)) | A type constructor |
TypeOp a (Qualified (OpName 'TypeOpName)) | A type operator. This will be desugared into a type constructor during the "operators" phase of desugaring. |
TypeApp a (Type a) (Type a) | A type application |
KindApp a (Type a) (Type a) | Explicit kind application |
ForAll a TypeVarVisibility Text (Maybe (Type a)) (Type a) (Maybe SkolemScope) | Forall quantifier |
ConstrainedType a (Constraint a) (Type a) | A type with a set of type class constraints |
Skolem a Text (Maybe (Type a)) Int SkolemScope | A skolem constant |
REmpty a | An empty row |
RCons a Label (Type a) (Type a) | A non-empty row |
KindedType a (Type a) (Type a) | A type with a kind annotation |
BinaryNoParensType a (Type a) (Type a) (Type a) | Binary operator application. During the rebracketing phase of desugaring, this data constructor will be removed. |
ParensInType a (Type a) | Explicit parentheses. During the rebracketing phase of desugaring, this data constructor will be removed. Note: although it seems this constructor is not used, it _is_ useful, since it prevents certain traversals from matching. |
Instances
srcTUnknown :: Int -> SourceType Source #
srcTypeVar :: Text -> SourceType Source #
srcTypeLevelInt :: Integer -> SourceType Source #
srcTypeApp :: SourceType -> SourceType -> SourceType Source #
srcKindApp :: SourceType -> SourceType -> SourceType Source #
srcForAll :: TypeVarVisibility -> Text -> Maybe SourceType -> SourceType -> Maybe SkolemScope -> SourceType Source #
srcRCons :: Label -> SourceType -> SourceType -> SourceType Source #
srcKindedType :: SourceType -> SourceType -> SourceType Source #
data ConstraintData Source #
Additional data relevant to type class constraints
PartialConstraintData [[Text]] Bool | Data to accompany a Partial constraint generated by the exhaustivity checker.
It contains (rendered) binder information for those binders which were
not matched, and a flag indicating whether the list was truncated or not.
Note: we use |
Instances
data Constraint a Source #
A typeclass constraint
Constraint | |
|
Instances
srcConstraint :: Qualified (ProperName 'ClassName) -> [SourceType] -> [SourceType] -> Maybe ConstraintData -> SourceConstraint Source #
mapConstraintArgs :: ([Type a] -> [Type a]) -> Constraint a -> Constraint a Source #
overConstraintArgs :: Functor f => ([Type a] -> f [Type a]) -> Constraint a -> f (Constraint a) Source #
mapConstraintArgsAll :: ([Type a] -> [Type a]) -> Constraint a -> Constraint a Source #
overConstraintArgsAll :: Applicative f => ([Type a] -> f [Type a]) -> Constraint a -> f (Constraint a) Source #
constraintToJSON :: (a -> Value) -> Constraint a -> Value Source #
constraintFromJSON :: forall a. Parser a -> (Value -> Parser a) -> Value -> Parser (Constraint a) Source #
data RowListItem a Source #
RowListItem | |
|
Instances
srcRowListItem :: Label -> SourceType -> RowListItem SourceAnn Source #
rowToList :: Type a -> ([RowListItem a], Type a) Source #
Convert a row to a list of pairs of labels and types
rowToSortedList :: Type a -> ([RowListItem a], Type a) Source #
Convert a row to a list of pairs of labels and types, sorted by the labels.
rowFromList :: ([RowListItem a], Type a) -> Type a Source #
Convert a list of labels and types to a row
alignRowsWith :: (Label -> Type a -> Type a -> r) -> Type a -> Type a -> ([r], (([RowListItem a], Type a), ([RowListItem a], Type a))) Source #
Align two rows of types, splitting them into three parts:
- Those types which appear in both rows
- Those which appear only on the left
- Those which appear only on the right
Note: importantly, we preserve the order of the types with a given label.
isMonoType :: Type a -> Bool Source #
Check whether a type is a monotype
replaceTypeVars :: Text -> Type a -> Type a -> Type a Source #
Replace a type variable, taking into account variable shadowing
replaceAllTypeVars :: [(Text, Type a)] -> Type a -> Type a Source #
Replace named type variables with types
addVisibility :: [(Text, TypeVarVisibility)] -> Type a -> Type a Source #
Add visible type abstractions to top-level foralls.
usedTypeVariables :: Type a -> [Text] Source #
Collect all type variables appearing in a type
freeTypeVariables :: Type a -> [Text] Source #
Collect all free type variables appearing in a type
completeBinderList :: Type a -> Maybe ([(a, (Text, Type a))], Type a) Source #
Collect a complete set of kind-annotated quantifiers at the front of a type.
quantify :: Type a -> Type a Source #
Universally quantify over all type variables appearing free in a type
moveQuantifiersToFront :: Type a -> Type a Source #
Move all universal quantifiers to the front of a type
containsForAll :: Type a -> Bool Source #
Check if a type contains forall
containsUnknowns :: Type a -> Bool Source #
Check if a type contains unknowns in a position that is relevant to constraint solving. (Kinds are not.)
eraseKindApps :: Type a -> Type a Source #
eraseForAllKindAnnotations :: Type a -> Type a Source #
unapplyConstraints :: Type a -> ([Constraint a], Type a) Source #
srcInstanceType :: SourceSpan -> [(Text, SourceType)] -> Qualified (ProperName 'ClassName) -> [SourceType] -> SourceType Source #
Construct the type of an instance declaration from its parts. Used in error messages describing unnamed instances.
everythingOnTypes :: (r -> r -> r) -> (Type a -> r) -> Type a -> r Source #
everythingWithContextOnTypes :: s -> r -> (r -> r -> r) -> (s -> Type a -> (s, r)) -> Type a -> r Source #
annForType :: Lens' (Type a) a Source #
getAnnForType :: Type a -> a Source #
setAnnForType :: a -> Type a -> Type a Source #
eqConstraint :: Constraint a -> Constraint b -> Bool Source #
compareConstraint :: Constraint a -> Constraint b -> Ordering Source #