clash-lib-1.8.1: Clash: a functional hardware description language - As a library
Copyright(C) 2012-2016 University of Twente
2017 Google Inc.
2021 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Core.Term

Description

Term representation in the CoreHW language: System F + LetRec + Case

Synopsis

Documentation

data Term Source #

Term representation in the CoreHW language: System F + LetRec + Case

Constructors

Var !Id

Variable reference

Data !DataCon

Datatype constructor

Literal !Literal

Literal

Prim !PrimInfo

Primitive

Lam !Id Term

Term-abstraction

TyLam !TyVar Term

Type-abstraction

App !Term !Term

Application

TyApp !Term !Type

Type-application

Let !(Bind Term) Term

Recursive let-binding

Case !Term !Type [Alt]

Case-expression: subject, type of alternatives, list of alternatives

Cast !Term !Type !Type

Cast a term from one type to another

Tick !TickInfo !Term

Annotated term

Bundled Patterns

pattern Letrec :: [LetBinding] -> Term -> Term 

Instances

Instances details
Eq Term Source # 
Instance details

Defined in Clash.Core.Subst

Methods

(==) :: Term -> Term -> Bool Source #

(/=) :: Term -> Term -> Bool Source #

Ord Term Source # 
Instance details

Defined in Clash.Core.Subst

Show Term Source # 
Instance details

Defined in Clash.Core.Term

Generic Term Source # 
Instance details

Defined in Clash.Core.Term

Associated Types

type Rep Term :: Type -> Type Source #

Methods

from :: Term -> Rep Term x Source #

to :: Rep Term x -> Term Source #

(TypeError (('Text "A broken implementation of Hashable Term has been " :<>: 'Text "removed in Clash 1.4.7. If this is an issue for you, please submit ") :<>: 'Text "an issue report at https://github.com/clash-lang/clash-compiler/issues.") :: Constraint) => Hashable Term Source # 
Instance details

Defined in Clash.Core.Subst

Binary Term Source # 
Instance details

Defined in Clash.Core.Term

NFData Term Source # 
Instance details

Defined in Clash.Core.Term

Methods

rnf :: Term -> () Source #

ClashPretty Term Source # 
Instance details

Defined in Clash.Core.Pretty

Methods

clashPretty :: Term -> Doc () Source #

PrettyPrec Term Source # 
Instance details

Defined in Clash.Core.Pretty

HasFreeVars Term Source # 
Instance details

Defined in Clash.Core.HasFreeVars

TermLiteral Term Source # 
Instance details

Defined in Clash.Core.TermLiteral

InferType Term Source # 
Instance details

Defined in Clash.Core.HasType

PrettyPrec (Id, Term) Source # 
Instance details

Defined in Clash.Core.Pretty

type Rep Term Source # 
Instance details

Defined in Clash.Core.Term

type Rep Term = D1 ('MetaData "Term" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) (((C1 ('MetaCons "Var" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Id)) :+: (C1 ('MetaCons "Data" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DataCon)) :+: C1 ('MetaCons "Literal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Literal)))) :+: (C1 ('MetaCons "Prim" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PrimInfo)) :+: (C1 ('MetaCons "Lam" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Id) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Term)) :+: C1 ('MetaCons "TyLam" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TyVar) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Term))))) :+: ((C1 ('MetaCons "App" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term)) :+: (C1 ('MetaCons "TyApp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Type)) :+: C1 ('MetaCons "Let" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Bind Term)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Term)))) :+: (C1 ('MetaCons "Case" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Type) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Alt]))) :+: (C1 ('MetaCons "Cast" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Type) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Type))) :+: C1 ('MetaCons "Tick" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TickInfo) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term))))))

mkAbstraction :: Term -> [Either Id TyVar] -> Term Source #

Abstract a term over a list of term and type variables

mkTyLams :: Term -> [TyVar] -> Term Source #

Abstract a term over a list of type variables

mkLams :: Term -> [Id] -> Term Source #

Abstract a term over a list of variables

mkApps :: Term -> [Either Term Type] -> Term Source #

Apply a list of types and terms to a term

mkTyApps :: Term -> [Type] -> Term Source #

Apply a list of types to a term

mkTmApps :: Term -> [Term] -> Term Source #

Apply a list of terms to a term

type TmName = Name Term Source #

Term reference

varToId :: Term -> Id Source #

Make a term variable out of a variable reference or ticked variable reference

data Bind a Source #

Constructors

NonRec Id a 
Rec [(Id, a)] 

Instances

Instances details
Functor Bind Source # 
Instance details

Defined in Clash.Core.Term

Methods

fmap :: (a -> b) -> Bind a -> Bind b Source #

(<$) :: a -> Bind b -> Bind a Source #

Eq a => Eq (Bind a) Source # 
Instance details

Defined in Clash.Core.Term

Methods

(==) :: Bind a -> Bind a -> Bool Source #

(/=) :: Bind a -> Bind a -> Bool Source #

Show a => Show (Bind a) Source # 
Instance details

Defined in Clash.Core.Term

Methods

showsPrec :: Int -> Bind a -> ShowS Source #

show :: Bind a -> String Source #

showList :: [Bind a] -> ShowS Source #

Generic (Bind a) Source # 
Instance details

Defined in Clash.Core.Term

Associated Types

type Rep (Bind a) :: Type -> Type Source #

Methods

from :: Bind a -> Rep (Bind a) x Source #

to :: Rep (Bind a) x -> Bind a Source #

Hashable a => Hashable (Bind a) Source # 
Instance details

Defined in Clash.Core.Term

Methods

hashWithSalt :: Int -> Bind a -> Int Source #

hash :: Bind a -> Int Source #

Binary a => Binary (Bind a) Source # 
Instance details

Defined in Clash.Core.Term

Methods

put :: Bind a -> Put Source #

get :: Get (Bind a) Source #

putList :: [Bind a] -> Put Source #

NFData a => NFData (Bind a) Source # 
Instance details

Defined in Clash.Core.Term

Methods

rnf :: Bind a -> () Source #

type Rep (Bind a) Source # 
Instance details

Defined in Clash.Core.Term

type LetBinding = (Id, Term) Source #

Binding in a LetRec construct

data Pat Source #

Patterns in the LHS of a case-decomposition

Constructors

DataPat !DataCon [TyVar] [Id]

Datatype pattern, '[TyVar]' bind existentially-quantified type-variables of a DataCon

LitPat !Literal

Literal pattern

DefaultPat

Default pattern

Instances

Instances details
Eq Pat Source # 
Instance details

Defined in Clash.Core.Term

Methods

(==) :: Pat -> Pat -> Bool Source #

(/=) :: Pat -> Pat -> Bool Source #

Ord Pat Source # 
Instance details

Defined in Clash.Core.Term

Methods

compare :: Pat -> Pat -> Ordering Source #

(<) :: Pat -> Pat -> Bool Source #

(<=) :: Pat -> Pat -> Bool Source #

(>) :: Pat -> Pat -> Bool Source #

(>=) :: Pat -> Pat -> Bool Source #

max :: Pat -> Pat -> Pat Source #

min :: Pat -> Pat -> Pat Source #

Show Pat Source # 
Instance details

Defined in Clash.Core.Term

Generic Pat Source # 
Instance details

Defined in Clash.Core.Term

Associated Types

type Rep Pat :: Type -> Type Source #

Methods

from :: Pat -> Rep Pat x Source #

to :: Rep Pat x -> Pat Source #

Binary Pat Source # 
Instance details

Defined in Clash.Core.Term

Methods

put :: Pat -> Put Source #

get :: Get Pat Source #

putList :: [Pat] -> Put Source #

NFData Pat Source # 
Instance details

Defined in Clash.Core.Term

Methods

rnf :: Pat -> () Source #

PrettyPrec Pat Source # 
Instance details

Defined in Clash.Core.Pretty

type Rep Pat Source # 
Instance details

Defined in Clash.Core.Term

patIds :: Pat -> ([TyVar], [Id]) Source #

Get the list of term-binders out of a DataType pattern

patVars :: Pat -> [Var a] Source #

type Alt = (Pat, Term) Source #

data TickInfo Source #

Constructors

SrcSpan !SrcSpan

Source tick, will get added by GHC by running clash with `-g`

NameMod !NameMod !Type

Modifier for naming module instantiations and registers, are added by the user by using the functions Clash.Magic.[prefixName,suffixName,setName]

DeDup

Deduplicate, i.e. try to share expressions between multiple branches.

NoDeDup

Do not deduplicate, i.e. keep, an expression inside a case-alternative; do not try to share expressions between multiple branches.

Instances

Instances details
Eq TickInfo Source # 
Instance details

Defined in Clash.Core.Term

Ord TickInfo Source # 
Instance details

Defined in Clash.Core.Term

Show TickInfo Source # 
Instance details

Defined in Clash.Core.Term

Generic TickInfo Source # 
Instance details

Defined in Clash.Core.Term

Associated Types

type Rep TickInfo :: Type -> Type Source #

Binary TickInfo Source # 
Instance details

Defined in Clash.Core.Term

NFData TickInfo Source # 
Instance details

Defined in Clash.Core.Term

Methods

rnf :: TickInfo -> () Source #

PrettyPrec TickInfo Source # 
Instance details

Defined in Clash.Core.Pretty

type Rep TickInfo Source # 
Instance details

Defined in Clash.Core.Term

stripAllTicks :: Term -> Term Source #

Like stripTicks but removes all ticks from subexpressions.

partitionTicks Source #

Arguments

:: [TickInfo] 
-> ([TickInfo], [TickInfo])

(source ticks, nameMod ticks)

Partition ticks in source ticks and nameMod ticks

data NameMod Source #

Tag to indicate which instance/register name modifier was used

Constructors

PrefixName
Clash.Magic.prefixName
SuffixName
Clash.Magic.suffixName
SuffixNameP
Clash.Magic.suffixNameP
SetName
Clash.Magic.setName

Instances

Instances details
Eq NameMod Source # 
Instance details

Defined in Clash.Core.Term

Ord NameMod Source # 
Instance details

Defined in Clash.Core.Term

Show NameMod Source # 
Instance details

Defined in Clash.Core.Term

Generic NameMod Source # 
Instance details

Defined in Clash.Core.Term

Associated Types

type Rep NameMod :: Type -> Type Source #

Hashable NameMod Source # 
Instance details

Defined in Clash.Core.Term

Binary NameMod Source # 
Instance details

Defined in Clash.Core.Term

NFData NameMod Source # 
Instance details

Defined in Clash.Core.Term

Methods

rnf :: NameMod -> () Source #

type Rep NameMod Source # 
Instance details

Defined in Clash.Core.Term

type Rep NameMod = D1 ('MetaData "NameMod" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) ((C1 ('MetaCons "PrefixName" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SuffixName" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "SuffixNameP" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SetName" 'PrefixI 'False) (U1 :: Type -> Type)))

data PrimInfo Source #

Constructors

PrimInfo 

Fields

Instances

Instances details
Show PrimInfo Source # 
Instance details

Defined in Clash.Core.Term

Generic PrimInfo Source # 
Instance details

Defined in Clash.Core.Term

Associated Types

type Rep PrimInfo :: Type -> Type Source #

Binary PrimInfo Source # 
Instance details

Defined in Clash.Core.Term

NFData PrimInfo Source # 
Instance details

Defined in Clash.Core.Term

Methods

rnf :: PrimInfo -> () Source #

HasType PrimInfo Source # 
Instance details

Defined in Clash.Core.HasType

type Rep PrimInfo Source # 
Instance details

Defined in Clash.Core.Term

data PrimUnfolding Source #

Constructors

NoUnfolding 
Unfolding !Id 

Instances

Instances details
Eq PrimUnfolding Source # 
Instance details

Defined in Clash.Core.Term

Show PrimUnfolding Source # 
Instance details

Defined in Clash.Core.Term

Generic PrimUnfolding Source # 
Instance details

Defined in Clash.Core.Term

Associated Types

type Rep PrimUnfolding :: Type -> Type Source #

Hashable PrimUnfolding Source # 
Instance details

Defined in Clash.Core.Term

Binary PrimUnfolding Source # 
Instance details

Defined in Clash.Core.Term

NFData PrimUnfolding Source # 
Instance details

Defined in Clash.Core.Term

Methods

rnf :: PrimUnfolding -> () Source #

type Rep PrimUnfolding Source # 
Instance details

Defined in Clash.Core.Term

type Rep PrimUnfolding = D1 ('MetaData "PrimUnfolding" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) (C1 ('MetaCons "NoUnfolding" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Unfolding" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Id)))

data IsMultiPrim Source #

Constructors

SingleResult 
MultiResult 

Instances

Instances details
Eq IsMultiPrim Source # 
Instance details

Defined in Clash.Core.Term

Show IsMultiPrim Source # 
Instance details

Defined in Clash.Core.Term

Generic IsMultiPrim Source # 
Instance details

Defined in Clash.Core.Term

Associated Types

type Rep IsMultiPrim :: Type -> Type Source #

Hashable IsMultiPrim Source # 
Instance details

Defined in Clash.Core.Term

Binary IsMultiPrim Source # 
Instance details

Defined in Clash.Core.Term

NFData IsMultiPrim Source # 
Instance details

Defined in Clash.Core.Term

Methods

rnf :: IsMultiPrim -> () Source #

type Rep IsMultiPrim Source # 
Instance details

Defined in Clash.Core.Term

type Rep IsMultiPrim = D1 ('MetaData "IsMultiPrim" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) (C1 ('MetaCons "SingleResult" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MultiResult" 'PrefixI 'False) (U1 :: Type -> Type))

data WorkInfo Source #

Constructors

WorkConstant

Ignores its arguments, and outputs a constant

WorkNever

Never adds any work

WorkVariable

Does work when the arguments are variable

WorkAlways

Performs work regardless of whether the variables are constant or variable; these are things like clock or reset generators

WorkIdentity Int [Int]

A more restrictive version of WorkNever, where the value is the argument at the given position if all arguments for the given list of positions are also WorkIdentity

Instances

Instances details
Eq WorkInfo Source # 
Instance details

Defined in Clash.Core.Term

Show WorkInfo Source # 
Instance details

Defined in Clash.Core.Term

Generic WorkInfo Source # 
Instance details

Defined in Clash.Core.Term

Associated Types

type Rep WorkInfo :: Type -> Type Source #

Hashable WorkInfo Source # 
Instance details

Defined in Clash.Core.Term

Binary WorkInfo Source # 
Instance details

Defined in Clash.Core.Term

NFData WorkInfo Source # 
Instance details

Defined in Clash.Core.Term

Methods

rnf :: WorkInfo -> () Source #

type Rep WorkInfo Source # 
Instance details

Defined in Clash.Core.Term

type Rep WorkInfo = D1 ('MetaData "WorkInfo" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) ((C1 ('MetaCons "WorkConstant" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WorkNever" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "WorkVariable" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WorkAlways" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WorkIdentity" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Int])))))

data CoreContext Source #

Context in which a term appears

Constructors

AppFun

Function position of an application

AppArg (Maybe (Text, Int, Int))

Argument position of an application. If this is an argument applied to a primitive, a tuple is defined containing (name of the primitive, #type args, #term args)

TyAppC

Function position of a type application

LetBinding Id [Id]

RHS of a Let-binder with the sibling LHS'

LetBody [LetBinding]

Body of a Let-binding with the bound LHS'

LamBody Id

Body of a lambda-term with the abstracted variable

TyLamBody TyVar

Body of a TyLambda-term with the abstracted type-variable

CaseAlt Pat

RHS of a case-alternative with the bound pattern on the LHS

CaseScrut

Subject of a case-decomposition

CastBody

Body of a Cast

TickC TickInfo

Body of a Tick

Instances

Instances details
Eq CoreContext Source # 
Instance details

Defined in Clash.Core.Term

Show CoreContext Source # 
Instance details

Defined in Clash.Core.Term

Generic CoreContext Source # 
Instance details

Defined in Clash.Core.Term

Associated Types

type Rep CoreContext :: Type -> Type Source #

Binary CoreContext Source # 
Instance details

Defined in Clash.Core.Term

NFData CoreContext Source # 
Instance details

Defined in Clash.Core.Term

Methods

rnf :: CoreContext -> () Source #

type Rep CoreContext Source # 
Instance details

Defined in Clash.Core.Term

type Rep CoreContext = D1 ('MetaData "CoreContext" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) (((C1 ('MetaCons "AppFun" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AppArg" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Text, Int, Int))))) :+: (C1 ('MetaCons "TyAppC" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LetBinding" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Id) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Id])) :+: C1 ('MetaCons "LetBody" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [LetBinding]))))) :+: ((C1 ('MetaCons "LamBody" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Id)) :+: (C1 ('MetaCons "TyLamBody" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TyVar)) :+: C1 ('MetaCons "CaseAlt" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pat)))) :+: (C1 ('MetaCons "CaseScrut" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "CastBody" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TickC" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TickInfo))))))

type Context = [CoreContext] Source #

A list of CoreContext describes the complete navigation path from the top-level to a specific sub-expression.

isLambdaBodyCtx :: CoreContext -> Bool Source #

Is the Context a Lambda/Term-abstraction context?

isTickCtx :: CoreContext -> Bool Source #

Is the Context a Tick context?

walkTerm :: forall a. (Term -> Maybe a) -> Term -> [a] Source #

Visit all terms in a term, testing it with a predicate, and returning a list of predicate yields.

collectArgs :: Term -> (Term, [Either Term Type]) Source #

Split a (Type)Application in the applied term and it arguments

collectBndrs :: Term -> ([Either Id TyVar], Term) Source #

Split a (Type)Abstraction in the bound variables and the abstracted term

primArg Source #

Arguments

:: Term

Function application

-> Maybe (Text, Int, Int)

If Term was a primitive: (name of primitive, #type args, #term args)

Given a function application, find the primitive it's applied. Yields Nothing if given term is not an application or if it is not a primitive.