clash-lib-1.2.2: CAES Language for Synchronous Hardware - As a Library
Safe HaskellNone
LanguageHaskell2010

Clash.Core.TermInfo

Synopsis

Documentation

termType :: TyConMap -> Term -> Type Source #

Determine the type of a term

applyTypeToArgs :: Term -> TyConMap -> Type -> [Either Term Type] -> Type Source #

Get the result type of a polymorphic function given a list of arguments

piResultTy :: HasCallStack => TyConMap -> Type -> Type -> Type Source #

Like piResultTyMaybe, but errors out when a type application is not valid.

Do not iterate piResultTy, because it's inefficient to substitute one variable at a time; instead use piResultTys

piResultTyMaybe :: HasCallStack => TyConMap -> Type -> Type -> Maybe Type Source #

Like piResultTys but for a single argument.

Do not iterate piResultTyMaybe, because it's inefficient to substitute one variable at a time; instead use piResultTys

piResultTys :: HasCallStack => TyConMap -> Type -> [Type] -> Type Source #

(piResultTys f_ty [ty1, ..., tyn]) give sthe type of (f ty1 .. tyn) where f :: f_ty

piResultTys is interesting because:

  1. f_ty may have more foralls than there are args
  2. Less obviously, it may have fewer foralls

Fore case 2. think of:

piResultTys (forall a . a) [forall b.b, Int]

This really can happen, such as situations involving undefineds type:

undefined :: forall a. a

undefined (forall b. b -> b) Int

This term should have the type (Int -> Int), but notice that there are more type args than foralls in undefineds type.

For efficiency reasons, when there are no foralls, we simply drop arrows from a function type/kind.

isFun :: TyConMap -> Term -> Bool Source #

Does a term have a function type?

isPolyFun :: TyConMap -> Term -> Bool Source #

Does a term have a function or polymorphic type?

isLam :: Term -> Bool Source #

Is a term a term-abstraction?

isLet :: Term -> Bool Source #

Is a term a recursive let-binding?

isVar :: Term -> Bool Source #

Is a term a variable reference?

isCon :: Term -> Bool Source #

Is a term a datatype constructor?

isPrim :: Term -> Bool Source #

Is a term a primitive?