clash-lib-1.4.0: Clash: a functional hardware description language - As a library
Safe HaskellNone
LanguageHaskell2010

Clash.Core.TermInfo

Synopsis

Documentation

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

Determine the type of a term

multiPrimType :: PrimInfo -> Type Source #

Type of multi prim primitive belonging to given primitive. See setupMultiResultPrim for more information.

Example, given:

  /v1 -> t1 -> t2 -> (t3, t4)

produces:

  /v1 -> t1 -> t2 -> t3 -> t4 -> (t3, t4)

multiPrimInfo' :: HasCallStack => TyConMap -> PrimInfo -> MultiPrimInfo Source #

Same as multiPrimInfo, but produced an error if it could not produce a MultiPrimInfo.

multiPrimInfo :: TyConMap -> PrimInfo -> Maybe MultiPrimInfo Source #

Produce MutliPrimInfo for given primitive

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]) gives the 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?

isCast :: Term -> Bool Source #

Is a term a cast?