feldspar-language- A functional embedded language for DSP and parallelism



This module defines the concept of expressions and expression transformers.

An expression is a type constructor of kind

 * -> * -> *

where the first argument denotes the "role" of the expression, and the second argument is the type of the value computed by the expression.

An expression transformer is a type constructor of kind

 (* -> * -> *) -> (* -> * -> *)

i.e. a expression parameterized by an expression.



data Empty role a Source

Expression type with no constructors. Can be used to turn an expression transformer to an expression.


class ExprEq expr whereSource

Equality for expressions. The difference between Eq and ExprEq is that ExprEq allows comparison of expressions with different role and value type. It is assumed that when the types differ, the expressions also differ. The reason for allowing comparison of different types is that this is convenient when the types are existentially quantified.


exprEq :: expr ra a -> expr rb b -> BoolSource


ExprEq Empty 
ExprEq Val 
ExprEq Feldspar 
ExprEq expr => ExprEq (Lam expr) 
ExprEq node => ExprEq (Connection edge node) 

class Eval expr whereSource

Evaluation of expressions


eval :: expr role a -> aSource


Eval Empty 
Eval Val 
Eval Feldspar 
Eval expr => Eval (Lam expr) 
Eval node => Eval (Connection edge node) 

class ExprShow expr whereSource


exprShow :: expr role a -> StringSource


printExpr :: ExprShow expr => expr role a -> IO ()Source

exprCast :: forall expr ra a rb b. (Typeable ra, Typeable a, Typeable rb, Typeable b) => expr ra a -> Maybe (expr rb b)Source

Type-safe cast for expressions