futhark
Safe HaskellNone
LanguageGHC2021

Language.Futhark.TypeChecker.Constraints

Description

Constraints produced (and solved) by the type checker.

Synopsis

Documentation

data Reason t Source #

The reason for a type constraint. Used to generate type error messages. The expected type is always the first one.

Constructors

Reason Loc

No particular reason.

ReasonPatMatch Loc (PatBase (NoInfo :: Type -> Type) VName StructType) t

Arising from pattern match.

ReasonAscription Loc t t

Arising from explicit ascription.

ReasonRetType Loc t t 
ReasonApply Loc (Maybe (QualName VName), Int) Exp t t

Arising from checking a function argument. The types are the expected (parameter) and actual (argument) types.

ReasonApplySplit Loc (Maybe (QualName VName), Int) Exp t

Used when unifying a type with a function type in a function application. If this unification fails, it means the supposed function was not a function after all.

ReasonBranches Loc t t 

Instances

Instances details
Functor Reason Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

fmap :: (a -> b) -> Reason a -> Reason b #

(<$) :: a -> Reason b -> Reason a #

Foldable Reason Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

fold :: Monoid m => Reason m -> m #

foldMap :: Monoid m => (a -> m) -> Reason a -> m #

foldMap' :: Monoid m => (a -> m) -> Reason a -> m #

foldr :: (a -> b -> b) -> b -> Reason a -> b #

foldr' :: (a -> b -> b) -> b -> Reason a -> b #

foldl :: (b -> a -> b) -> b -> Reason a -> b #

foldl' :: (b -> a -> b) -> b -> Reason a -> b #

foldr1 :: (a -> a -> a) -> Reason a -> a #

foldl1 :: (a -> a -> a) -> Reason a -> a #

toList :: Reason a -> [a] #

null :: Reason a -> Bool #

length :: Reason a -> Int #

elem :: Eq a => a -> Reason a -> Bool #

maximum :: Ord a => Reason a -> a #

minimum :: Ord a => Reason a -> a #

sum :: Num a => Reason a -> a #

product :: Num a => Reason a -> a #

Traversable Reason Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

traverse :: Applicative f => (a -> f b) -> Reason a -> f (Reason b) #

sequenceA :: Applicative f => Reason (f a) -> f (Reason a) #

mapM :: Monad m => (a -> m b) -> Reason a -> m (Reason b) #

sequence :: Monad m => Reason (m a) -> m (Reason a) #

Show t => Show (Reason t) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

showsPrec :: Int -> Reason t -> ShowS #

show :: Reason t -> String #

showList :: [Reason t] -> ShowS #

Eq t => Eq (Reason t) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

(==) :: Reason t -> Reason t -> Bool #

(/=) :: Reason t -> Reason t -> Bool #

Located (Reason t) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

locOf :: Reason t -> Loc #

locOfList :: [Reason t] -> Loc #

type CtType d = TypeBase d NoMode Source #

The type representation used by the constraint solver.

data CtTy d Source #

A type constraint.

Constructors

CtEq (Reason (CtType d)) (TypeBase d NoMode) (TypeBase d NoMode) 

Instances

Instances details
Functor CtTy Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

fmap :: (a -> b) -> CtTy a -> CtTy b #

(<$) :: a -> CtTy b -> CtTy a #

Show d => Show (CtTy d) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

showsPrec :: Int -> CtTy d -> ShowS #

show :: CtTy d -> String #

showList :: [CtTy d] -> ShowS #

Pretty (CtTy Size) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

pretty :: CtTy Size -> Doc ann #

prettyList :: [CtTy Size] -> Doc ann #

Pretty (CtTy ()) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

pretty :: CtTy () -> Doc ann #

prettyList :: [CtTy ()] -> Doc ann #

Located (CtTy d) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

locOf :: CtTy d -> Loc #

locOfList :: [CtTy d] -> Loc #

data TyVarInfo d Source #

Information about a flexible type variable. Every type variable is associated with a location, which is the original syntax element that it is the type of.

Constructors

TyVarFree Loc Liftedness

Can be substituted with anything.

TyVarPrim Loc [PrimType]

Can only be substituted with these primitive types.

TyVarRecord Loc (Map Name (CtType d))

Must be a record with these fields.

TyVarSum Loc (Map Name [CtType d])

Must be a sum type with these fields.

Instances

Instances details
Functor TyVarInfo Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

fmap :: (a -> b) -> TyVarInfo a -> TyVarInfo b #

(<$) :: a -> TyVarInfo b -> TyVarInfo a #

Show d => Show (TyVarInfo d) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Eq d => Eq (TyVarInfo d) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

(==) :: TyVarInfo d -> TyVarInfo d -> Bool #

(/=) :: TyVarInfo d -> TyVarInfo d -> Bool #

Pretty (TyVarInfo ()) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

pretty :: TyVarInfo () -> Doc ann #

prettyList :: [TyVarInfo ()] -> Doc ann #

Located (TyVarInfo d) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Constraints

Methods

locOf :: TyVarInfo d -> Loc #

locOfList :: [TyVarInfo d] -> Loc #

type Level = Int Source #

The level at which a type variable is bound. Higher means deeper. We can only unify a type variable at level i with a type t if all type names that occur in t are at most at level i.

type TyVar = VName Source #

The name of a type variable.

type TyVars d = Map TyVar (Level, TyVarInfo d) Source #

If a VName is not in this map, it should be in the TyParams - the exception is abstract types, which are just missing (and assumed to have smallest possible level).

type TyParams = Map TyVar (Level, Liftedness, Loc) Source #

Explicit type parameters.