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

Safe HaskellNone
LanguageHaskell2010

CLaSH.Core.Util

Description

Smart constructor and destructor functions for CoreHW

Synopsis

Documentation

type Gamma = HashMap TmName Type Source

Type environment/context

type Delta = HashMap TyName Kind Source

Kind environment/context

termType :: (Functor m, Fresh m) => HashMap TyConName 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 TyConName 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 :: (Functor m, Fresh m) => HashMap TyConName TyCon -> Term -> m Bool Source

Does a term have a function type?

isPolyFun :: (Functor m, Fresh m) => HashMap TyConName 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

-> Int

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

-> Int

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

-> Int

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

isSignalType :: HashMap TyConName 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.