haskell-tools-refactor-1.1.1.0: Refactoring Tool for Haskell

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Tools.Refactor.Utils.TypeLookup

Contents

Synopsis

Documentation

lookupTypeFromId :: (HasIdInfo' id, GhcMonad m) => id -> MaybeT m Type Source #

Looks up the Type of an entity with an Id of any locality. If the entity being scrutinised is a type variable, it fails.

typeOrKindFromId :: HasIdInfo' id => id -> Type Source #

Looks up the Type or the Kind of an entity that has an Id. Note: In some cases we only get the Kind of the Id (e.g. for type constructors)

typeFromTyThing :: TyThing -> Maybe Type Source #

Extracts a Type from a TyThing when possible.

lookupTypeFromGlobalName :: (HasNameInfo' n, GhcMonad m) => n -> MaybeT m Type Source #

Looks up a GHC Type from a Haskell Tools Name (given the name is global) For an identifier, it returns its type. For a data constructor, it returns its type. For a pattern synonym, it returns its builder's type. For a type synonym constructor, it returns its right-hand side. For a coaxiom, it fails.

lookupTypeSynRhs :: (HasNameInfo' n, GhcMonad m) => n -> MaybeT m Type Source #

Looks up the right-hand side (GHC representation) of a Haskell Tools Name corresponding to a type synonym

lookupClassWith :: GhcMonad m => (a -> MaybeT m Name) -> a -> MaybeT m Class Source #

Looks up a GHC.Class from something that has a type class constructor in it Fails if the argument does not contain a class type constructor

semanticsTypeSynRhs :: GhcMonad m => Type -> MaybeT m Type Source #

Looks up the right-hand side (GHC representation) of a Haskell Tools Type corresponding to a type synonym

semanticsType :: GhcMonad m => Type -> MaybeT m Type Source #

Converts a global Haskell Tools type to a GHC type

satisfies :: (HasNameInfo' n, GhcMonad m) => (TyThing -> Maybe a) -> (a -> Bool) -> n -> MaybeT m Bool Source #

Looks up the given name, extracts something out of it. If the extraction is not succesful, it returns False, if it is successful, then checks the result against the predicate. The reasoning behind this, is that the predicate can only be satisfied by a proper name.

isClassTyConNameM :: (HasNameInfo' n, GhcMonad m) => n -> MaybeT m Bool Source #

Decides whether a given name is a type family constructor. Fails if the lookup is not successful.

isVanillaDataConNameM :: (HasNameInfo' n, GhcMonad m) => n -> MaybeT m Bool Source #

Decides whether a given name is a standard Haskell98 data constructor. Fails if the lookup is not successful.

lookupClosedTyFam :: (HasNameInfo' n, GhcMonad m) => n -> MaybeT m ClosedTyFam Source #

Looks up a closed type family from a name.

coAxiomFromTyThing :: TyThing -> Maybe (CoAxiom Branched) Source #

Extract the CoAxioms from a TyThing representing a closed type family.

hasTyVarHead :: Type -> Bool Source #

Determines whether a Type itself has a type variable head.

Orphan instances

Eq Type Source # 
Instance details

Methods

(==) :: Type -> Type -> Bool #

(/=) :: Type -> Type -> Bool #