Feldspar.Core.Frontend

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

Safe Haskell | None

Feldspar.Core.Frontend

Contents

- QuickCheck
- Type constraints
- Functions

Synopsis

- module Data.Patch
- class Syntactic a where
  - type Internal a :: *
- type SyntacticFeld a = (Syntactic a, Domain a ~ FeldDomainAll, Typeable (Internal a))
- type family Internal a :: *
- type FeldDomainAll = HODomain FeldSymbols Typeable Type
- data Data a
- class (Syntactic a, Domain a ~ FeldDomainAll, Type (Internal a)) => Syntax a
- reifyFeld :: SyntacticFeld a => BitWidth n -> a -> ASTF (Decor Info FeldDomain) (Internal a)
- showExpr :: SyntacticFeld a => a -> String
- printExpr :: SyntacticFeld a => a -> IO ()
- showAST :: SyntacticFeld a => a -> String
- drawAST :: SyntacticFeld a => a -> IO ()
- showDecor :: SyntacticFeld a => a -> String
- drawDecor :: SyntacticFeld a => a -> IO ()
- eval :: SyntacticFeld a => a -> Internal a
- evalTarget :: (SyntacticFeld a, BoundedInt (GenericInt U n), BoundedInt (GenericInt S n)) => BitWidth n -> a -> Internal a
- desugar :: Syntax a => a -> Data (Internal a)
- sugar :: Syntax a => Data (Internal a) -> a
- resugar :: (Syntax a, Syntax b, Internal a ~ Internal b) => a -> b
- (===>) :: Testable prop => Data Bool -> prop -> Property
- (===) :: Equal a => a -> a -> Property
- tData :: Patch a a -> Patch (Data a) (Data a)
- tArr1 :: Patch a a -> Patch (Data [a]) (Data [a])
- tArr2 :: Patch a a -> Patch (Data [[a]]) (Data [[a]])
- tM :: Patch a a -> Patch (M a) (M a)
- ilog2 :: Bits a => Data a -> Data Index
- nlz :: Bits a => Data a -> Data Index

# Documentation

module Data.Patch

class Syntactic a

It is usually assumed that `(`desugar` (`sugar` a))` has the same meaning as `a`.

Associated Types

type Internal a :: *

Instances

Syntactic () |
Type a => Syntactic (Data a) |
Syntax a => Syntactic (Future a) |
Syntax a => Syntactic (M a) |
Syntax a => Syntactic (Ref a) |
Syntax a => Syntactic (IVar a) |
Syntax a => Syntactic (P a) |
Syntax a => Syntactic (Vector a) |
Unit a => Syntactic (BitVector a) |
Type a => Syntactic (Fix a) |
Syntax a => Syntactic (Option a) |
Syntax a => Syntactic (PushVector a) |
(Syntactic a, ~ (* -> *) (Domain a) (HODomain dom p pVar), Syntactic b, ~ (* -> *) (Domain b) (HODomain dom p pVar), p (Internal a -> Internal b), p (Internal a), pVar (Internal a)) => Syntactic (a -> b) |
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, TupleSat dom p, p (Internal a, Internal b), p (Internal a), p (Internal b), InjectC (:|| Tuple p) dom (Internal a, Internal b), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b)) => Syntactic (a, b) |
Syntactic (ASTF dom a) |
Type a => Syntactic (Data' s a) |
(Shape sh, Syntax a) => Syntactic (Vector sh a) |
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, TupleSat dom p, p (Internal a, Internal b, Internal c), p (Internal a), p (Internal b), p (Internal c), InjectC (:|| Tuple p) dom (Internal a, Internal b, Internal c), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b), InjectC (:|| Select p) dom (Internal c)) => Syntactic (a, b, c) |
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, TupleSat dom p, p (Internal a, Internal b, Internal c, Internal d), p (Internal a), p (Internal b), p (Internal c), p (Internal d), InjectC (:|| Tuple p) dom (Internal a, Internal b, Internal c, Internal d), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b), InjectC (:|| Select p) dom (Internal c), InjectC (:|| Select p) dom (Internal d)) => Syntactic (a, b, c, d) |
(Syntactic a, ~ (* -> *) (Domain a) (HODomain dom Typeable pVar), InjectC (MONAD m) dom (m (Internal a)), Monad m, Typeable1 m, Typeable (Internal a), pVar (Internal a)) => Syntactic (Mon dom pVar m a) |
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, Syntactic e, ~ (* -> *) (Domain e) dom, TupleSat dom p, p (Internal a, Internal b, Internal c, Internal d, Internal e), p (Internal a), p (Internal b), p (Internal c), p (Internal d), p (Internal e), InjectC (:|| Tuple p) dom (Internal a, Internal b, Internal c, Internal d, Internal e), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b), InjectC (:|| Select p) dom (Internal c), InjectC (:|| Select p) dom (Internal d), InjectC (:|| Select p) dom (Internal e)) => Syntactic (a, b, c, d, e) |
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, Syntactic e, ~ (* -> *) (Domain e) dom, Syntactic f, ~ (* -> *) (Domain f) dom, TupleSat dom p, p (Internal a, Internal b, Internal c, Internal d, Internal e, Internal f), p (Internal a), p (Internal b), p (Internal c), p (Internal d), p (Internal e), p (Internal f), InjectC (:|| Tuple p) dom (Internal a, Internal b, Internal c, Internal d, Internal e, Internal f), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b), InjectC (:|| Select p) dom (Internal c), InjectC (:|| Select p) dom (Internal d), InjectC (:|| Select p) dom (Internal e), InjectC (:|| Select p) dom (Internal f)) => Syntactic (a, b, c, d, e, f) |
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, Syntactic e, ~ (* -> *) (Domain e) dom, Syntactic f, ~ (* -> *) (Domain f) dom, Syntactic g, ~ (* -> *) (Domain g) dom, TupleSat dom p, p (Internal a, Internal b, Internal c, Internal d, Internal e, Internal f, Internal g), p (Internal a), p (Internal b), p (Internal c), p (Internal d), p (Internal e), p (Internal f), p (Internal g), InjectC (:|| Tuple p) dom (Internal a, Internal b, Internal c, Internal d, Internal e, Internal f, Internal g), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b), InjectC (:|| Select p) dom (Internal c), InjectC (:|| Select p) dom (Internal d), InjectC (:|| Select p) dom (Internal e), InjectC (:|| Select p) dom (Internal f), InjectC (:|| Select p) dom (Internal g)) => Syntactic (a, b, c, d, e, f, g) |

type SyntacticFeld a = (Syntactic a, Domain a ~ FeldDomainAll, Typeable (Internal a))

type family Internal a :: *

type FeldDomainAll = HODomain FeldSymbols Typeable Type

data Data a

Instances

Typeable1 Data |
Type a => Eq (Data a) |
Fraction a => Fractional (Data a) |
Numeric a => Num (Data a) |
Type a => Show (Data a) |
Type a => Annotatable (Data a) |
Testable (Data Bool) |
(Type a, Arbitrary a) => Arbitrary (Data a) |
Type a => Syntactic (Data a) |
Type a => Sized (Data [a]) |
Type a => Indexed (Data [a]) |
Type a => Syntax (Data a) |
Type a => Splittable (Data a) |
Fixable (Data Float) |
Type a => ElemWise (Data a) |
(Type a, Type b) => CollMap (Data [a]) (Data [b]) |
Wrap (Data a) (Data a) | Basic instances to handle `Data a` input and output. Other instances are located in the concerned libraries.
Type a => Wrap (Vector (Data a)) (Data [a]) |
Unit w => Wrap (BitVector w) (Data [w]) |
Type a => Wrap (Matrix a) (Data [[a]]) |
Numeric a => Mul (Data a) (Matrix a) |
Numeric a => Mul (Data a) (Vector1 a) |
Numeric a => Mul (Data a) (Data a) |
Numeric a => Mul (Vector1 a) (Matrix a) |
Numeric a => Mul (Vector1 a) (Vector1 a) |
Numeric a => Mul (Vector1 a) (Data a) |
Numeric a => Mul (Matrix a) (Matrix a) |
Numeric a => Mul (Matrix a) (Vector1 a) |
Numeric a => Mul (Matrix a) (Data a) |
Slice sl => Slice (:. sl (Data Length)) |
Shape sh => Shape (:. sh (Data Length)) |
Wrap t u => Wrap (Data a -> t) (Data a -> u) |
(Wrap t u, Type a, Nat s) => Wrap (Vector1 a -> t) (Data' s [a] -> u) |
(Wrap t u, Type a, Nat row, Nat col) => Wrap (Matrix a -> t) (Data' (row, col) [[a]] -> u) |

class (Syntactic a, Domain a ~ FeldDomainAll, Type (Internal a)) => Syntax a

Specialization of the `Syntactic` class for the Feldspar domain

Instances

Syntax () |
Type a => Syntax (Data a) |
Syntax a => Syntax (Future a) |
Syntax a => Syntax (Ref a) |
Syntax a => Syntax (IVar a) |
Syntax a => Syntax (Vector a) |
Unit a => Syntax (BitVector a) |
Type a => Syntax (Fix a) |
Syntax a => Syntax (Option a) |
Syntax a => Syntax (PushVector a) |
(Syntax a, Syntax b) => Syntax (a, b) |
Type a => Syntax (Data' s a) |
(Shape sh, Syntax a) => Syntax (Vector sh a) |
(Syntax a, Syntax b, Syntax c) => Syntax (a, b, c) |
(Syntax a, Syntax b, Syntax c, Syntax d) => Syntax (a, b, c, d) |
(Syntax a, Syntax b, Syntax c, Syntax d, Syntax e) => Syntax (a, b, c, d, e) |
(Syntax a, Syntax b, Syntax c, Syntax d, Syntax e, Syntax f) => Syntax (a, b, c, d, e, f) |
(Syntax a, Syntax b, Syntax c, Syntax d, Syntax e, Syntax f, Syntax g) => Syntax (a, b, c, d, e, f, g) |

reifyFeld :: SyntacticFeld a => BitWidth n -> a -> ASTF (Decor Info FeldDomain) (Internal a)

Reification and optimization of a Feldspar program

showExpr :: SyntacticFeld a => a -> String

printExpr :: SyntacticFeld a => a -> IO ()

showAST :: SyntacticFeld a => a -> String

drawAST :: SyntacticFeld a => a -> IO ()

showDecor :: SyntacticFeld a => a -> String

Draw a syntax tree decorated with type and size information

drawDecor :: SyntacticFeld a => a -> IO ()

Draw a syntax tree decorated with type and size information

eval :: SyntacticFeld a => a -> Internal a

evalTarget :: (SyntacticFeld a, BoundedInt (GenericInt U n), BoundedInt (GenericInt S n)) => BitWidth n -> a -> Internal a

desugar :: Syntax a => a -> Data (Internal a)

sugar :: Syntax a => Data (Internal a) -> a

resugar :: (Syntax a, Syntax b, Internal a ~ Internal b) => a -> b

# QuickCheck

(===>) :: Testable prop => Data Bool -> prop -> Property

(===) :: Equal a => a -> a -> Property

# Type constraints

tData :: Patch a a -> Patch (Data a) (Data a)

tArr1 :: Patch a a -> Patch (Data [a]) (Data [a])

tArr2 :: Patch a a -> Patch (Data [[a]]) (Data [[a]])

tM :: Patch a a -> Patch (M a) (M a)

# Functions

ilog2 :: Bits a => Data a -> Data Index

Integer logarithm in base 2 Based on an algorithm in Hacker's Delight

nlz :: Bits a => Data a -> Data Index

Count leading zeros Based on an algorithm in Hacker's Delight