haskell-tools-builtin-refactorings-1.1.1.0: Refactoring Tool for Haskell

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Tools.Refactor.Builtin.ExtensionOrganizer.Checkers

Synopsis

Documentation

gblChkUndecidableInstances :: CheckNode Module Source #

If UndecidableInstances is turned on, it checks whether any type class or type family instances needs UndecidableInstances in the module.

gblChkUndecidableInstances' :: CheckNode Module Source #

Checks whether any type class or type family instances needs UndecidableInstances in the module.

chkClsInst :: ClsInst -> ExtMonad () Source #

If the type class instance requires UndecidableInstances, it adds the occurence with location of the instance.

clsInstNeedsUD :: ClsInst -> Bool Source #

Decides whether a type class instance requires UndecidableInstances.

chkFamInst :: FamInst -> ExtMonad () Source #

If the type class instance requires UndecidableInstances, it adds the occurence with location of the instance.

famInstNeedsUD :: FamInst -> Bool Source #

Decides whether a family instance requires UndecidableInstances. If it is a data family instance, it does not need the extension.

chkUndecidableInstancesDecl :: CheckNode Decl Source #

Checks a declaration whether it needs UndecidableInstances. (If the extension is turned on)

chkUndecidableInstancesDecl' :: CheckNode Decl Source #

Checks a declaration whether it needs UndecidableInstances. If a lookup is not successful, it keeps the extension.

chkUndecidableInstancesDeclMaybe :: Decl -> MaybeT ExtMonad Decl Source #

Checks a class declaration whether it has a type function in its context, or a closed type family declaration needs UndecidableInstances. For more information on the family check, see checkFamInstRhs. May fail on lookup.

chkTypeSynonymInstancesDecl :: CheckNode Decl Source #

We need to check declarations because we want to avoid checking type family instances

chkInstancesDeclWith :: CheckNode InstanceRule -> CheckNode Decl Source #

Checks an instance rule in declaration We need to check declarations because we want to avoid checking type family instances

chkInstanceRuleWith :: CheckNode InstanceHead -> CheckNode InstanceRule Source #

Checks and instance head in an instance rule

collectTyArgs :: InstanceHead -> [Type] Source #

Collects the type arguments in an instance declaration Type arguments are the the types that the class is being instantiated with

chkTypeOperatorsType :: CheckNode Type Source #

Checks a Type whether it contains any DeclHeads that amy need TypeOperators

chkTypeOperatorsAssertion :: CheckNode Assertion Source #

Checks an Assertion whether it contains any DeclHeads that amy need TypeOperators

chkTypeOperatorsInstHead :: CheckNode InstanceHead Source #

Checks an InstanceHEad whether it contains any DeclHeads that amy need TypeOperators

chkTypeOperatorsDecl :: CheckNode Decl Source #

Checks a Decl whether it contains any DeclHeads that amy need TypeOperators We check Decls to avoid getting multiple occurences of the same DeclHead (e.g. we would check it with and without parentheses)

gblChkQNamesForTypeEq :: CheckNode Module Source #

Checks whether any name's corresponding type in the module contains a type equality.

chkOperatorForTypeEq :: CheckNode Operator Source #

Checks an operator for syntactic evidence of a ~ b type equality if TypeFamilies or GADTs is turned on.

chkTypeFamiliesDecl :: CheckNode Decl Source #

Checks a declaration if TypeFamilies is turned on.

chkTypeFamiliesClassElement :: CheckNode ClassElement Source #

Checks a class element if TypeFamilies is turned on.

chkTypeFamiliesInstBodyDecl :: CheckNode InstBodyDecl Source #

Checks an instance body if TypeFamilies is turned on.

chkQNameForTyEqn :: QualifiedName -> MaybeT ExtMonad Bool Source #

Checks whether a given name's has a type equality operator in it. If the type lookup fails, it returns Nothing. If given a type variable, it returns False.

chkMultiParamTypeClassesDecl' :: CheckNode Decl Source #

Decides whether a class or instance declaration needs MultiParamTypeClasses Also handles the NullaryTypeClasses case

isMultiParamNeeded :: InstanceHead -> Bool Source #

Decides whether an instance declaration needs MultiParamTypeClasses Also handles the NullaryTypeClasses case

chkGADTsGadtConDecl :: CheckNode GadtConDecl Source #

Checks a GADT-style constructor if GADTSyntax is turned on. Sometimes GADTSyntax is sufficient and GADTs is not even needed.

chkConDeclForExistentials :: CheckNode ConDecl Source #

Checks a data constructor declaration if GADTs or ExistentialQuantification is turned on. This function is responsible for checking ExistentialQuantification as well. (there is no separate checker for that extension)

chkGADTsGadtConDecl' :: CheckNode GadtConDecl Source #

Checks whether a GADTs-style constructor declaration requires GADTs. If all data constructors are vanilla Haskell 98 data constructors , then only GADTSyntax is needed. If any constructor's lookup fails , we add MissingInformation.

chkConDeclForExistentials' :: CheckNode ConDecl Source #

Extracts the name from a ConDecl, and checks whether it is a vanilla data constructor. Ifthe lookup fails, adds MissingInformation.

chkClassesInside :: Type -> ExtMonad () Source #

Checks whether all type class applications in a type synonym rhs (that has kind Constraint) have only type variable heads. Returns False if a lookup inside is not succesful. If it isn't applied to a type that has kind Constraint, it may give false positive results.

chkFlexibleInstancesDecl :: CheckNode Decl Source #

We need to check declarations because we want to avoid checking type family instances

refact :: (Data (node dom stage), Data (inner dom stage)) => (inner dom stage -> inner dom stage) -> node dom stage -> node dom stage Source #

chkInstanceHead :: CheckNode InstanceHead Source #

Checks every single type argument in an instance declaration If the class being instantiated could not have been looked up, it keeps FlexibleInstances

chkTypeArg :: Class -> Type -> ExtMonad Type Source #

Checks a type argument of class whether it needs FlexibleInstances First checks the structure of the type argument opaquely Then, for type synonyms, it checks whether their GHC representation itself needs the extension.

Might find false positive occurences for phantom types: > type Phantom a b = [a] > instance C (Phantom a a) > instance C (Phantom a Int)

chkNormalTypeArg :: CheckNode Type Source #

Checks a type argument of class whether it has only (distinct) type variable arguments.

hasOnlyDistinctTyVars :: Type -> Bool Source #

Checks whether a GHC.Type is an application, and has only (distinct) type variable arguments Logic from TcValidity.tcInstHeadTyAppAllTyVars

dropCasts :: Type -> Type Source #

A local helper function from TcValidity

dropCastsB :: TyVarBinder -> TyVarBinder Source #

A local helper function from TcValidity

addExtension :: (MonadState ExtMap m, HasRange node) => Name -> node -> m node Source #

preprocessedSrc :: ModSummary -> String Source #

Returns the preprocessed source code. If it is not present, it returns an empty string.

chkCCMDeclHead :: CheckNode DeclHead Source #

Check a DeclHead for ConstrainedClassMethods. Adds the extension if it is needed or the lookup fails.

chkCCMDeclHead' :: DeclHead -> MaybeT ExtMonad Bool Source #

Helper function for chkCCMDeclHead. True = Lookup is succesful and ConstrainedClassMethods is needed False = Lookup is succesful, but CCM is not needed, or the argument is not a class DeclHead fails = Lookup is unsuccesful (either name or type lookup)

classNeedsCCM :: Class -> Bool Source #

Decides whether a class really needs the ConstrainedClassMethods extension A class needs CCM iff at least one of its class methods has a constraint with a non-empty type variable set, that contains only class type variables.