clash-lib-0.99: CAES Language for Synchronous Hardware - As a Library

Copyright(C) 2012-2016 University of Twente
LicenseBSD2 (see the file LICENSE)
MaintainerChristiaan Baaij <christiaan.baaij@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Core.Util

Description

Smart constructor and destructor functions for CoreHW

Synopsis

Documentation

type Gamma = HashMap TmOccName Type Source #

Type environment/context

type Delta = HashMap TyOccName Kind Source #

Kind environment/context

termType :: Fresh m => HashMap TyConOccName TyCon -> Term -> m Type Source #

Determine the type of a term

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

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

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

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

applyTypeToArgs :: Fresh m => HashMap TyConOccName TyCon -> Type -> [Either Term Type] -> m Type Source #

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

patIds :: Pat -> [Id] Source #

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

mkTyVar :: Kind -> TyName -> TyVar Source #

Make a type variable

mkId :: Type -> TmName -> Id Source #

Make a term variable

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 term variables

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

Abstract a term over a list of type variables

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

Apply a list of types and terms to a term

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

Apply a list of terms to a term

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

Apply a list of types to a term

isFun :: Fresh m => HashMap TyConOccName TyCon -> Term -> m Bool Source #

Does a term have a function type?

isPolyFun :: Fresh m => HashMap TyConOccName TyCon -> Term -> m 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?

idToVar :: Id -> Term Source #

Make variable reference out of term variable

varToId :: Term -> Id Source #

Make a term variable out of a variable reference

mkVec Source #

Arguments

:: DataCon

The Nil constructor

-> DataCon

The Cons (:>) constructor

-> Type

Element type

-> Integer

Length of the vector

-> [Term]

Elements to put in the vector

-> Term 

Create a vector of supplied elements

appendToVec Source #

Arguments

:: DataCon

The Cons (:>) constructor

-> Type

Element type

-> Term

The vector to append the elements to

-> Integer

Length of the vector

-> [Term]

Elements to append

-> Term 

Append elements to the supplied vector

extractElems Source #

Arguments

:: DataCon

The Cons (:>) constructor

-> Type

The element type

-> Char

Char to append to the bound variable names

-> Integer

Length of the vector

-> Term

The vector

-> [(Term, [LetBinding])] 

Create let-bindings with case-statements that select elements out of a vector. Returns both the variables to which element-selections are bound and the let-bindings

extractTElems Source #

Arguments

:: DataCon

The LR constructor

-> DataCon

The BR constructor

-> Type

The element type

-> Char

Char to append to the bound variable names

-> Integer

Depth of the tree

-> Term

The tree

-> ([Term], [LetBinding]) 

Create let-bindings with case-statements that select elements out of a tree. Returns both the variables to which element-selections are bound and the let-bindings

mkRTree Source #

Arguments

:: DataCon

The LR constructor

-> DataCon

The BR constructor

-> Type

Element type

-> Integer

Depth of the tree

-> [Term]

Elements to put in the tree

-> Term 

Create a vector of supplied elements

isSignalType :: HashMap TyConOccName TyCon -> Type -> Bool Source #

Determine whether a type is isomorphic to Clash.Signal.Internal.Signal'

It is i.e.:

  • Signal' clk a
  • (Signal' clk a, Signal' clk b)
  • Vec n (Signal' clk a)
  • data Wrap = W (Signal clk' Int)
  • etc.