raw-feldspar-0.2.1: Resource-Aware Feldspar

Safe HaskellNone
LanguageHaskell2010

Feldspar.Representation

Contents

Description

Internal representation of Feldspar programs

Synopsis

Object-language types

type TypeRep = Struct PrimType' PrimTypeRep Source #

Representation of all supported types

class (PrimType' a, Type a) => PrimType a Source #

Alias for the conjunction of PrimType' and Type

Instances

CompTypeClass PrimType Source # 

Methods

compType :: (PrimType a, MonadC m) => proxy1 PrimType -> proxy2 a -> m Type #

compLit :: (PrimType a, MonadC m) => proxy PrimType -> a -> m Exp #

(PrimType' a, Type a) => PrimType a Source # 

toTypeRep :: Struct PrimType' c a -> TypeRep a Source #

Convert any Struct with a PrimType constraint to a TypeRep

typeEq :: TypeRep a -> TypeRep b -> Maybe (Dict (a ~ b)) Source #

Check whether two type representations are equal

witTypeable :: TypeRep a -> Dict (Typeable a) Source #

Reflect a TypeRep to a Typeable constraint

data TypeRepFun a where Source #

Representation of supported value types + N-ary functions over such types

Constructors

ValT :: TypeRep a -> TypeRepFun a 
FunT :: TypeRep a -> TypeRepFun b -> TypeRepFun (a -> b) 

typeEqFun :: TypeRepFun a -> TypeRepFun b -> Maybe (Dict (a ~ b)) Source #

Check whether two type representations are equal

newtype Ref a Source #

Mutable variable

Constructors

Ref 

Instances

Eq (Ref a) Source # 

Methods

(==) :: Ref a -> Ref a -> Bool #

(/=) :: Ref a -> Ref a -> Bool #

type DRef a = Ref (Data a) Source #

Reference specialized to Data elements

data Arr a Source #

Mutable array

Instances

Eq (Arr a) Source #

== checks if two Arr use the same physical array. The length and offset are ignored.

Methods

(==) :: Arr a -> Arr a -> Bool #

(/=) :: Arr a -> Arr a -> Bool #

Slicable (Arr a) Source # 

Methods

slice :: Data Index -> Data Length -> Arr a -> Arr a Source #

Finite (Arr a) Source # 

Methods

length :: Arr a -> Data Length Source #

(MarshalHaskell (Internal a), MarshalFeld a, Syntax a) => MarshalFeld (Arr a) Source # 

Associated Types

type HaskellRep (Arr a) :: * Source #

Methods

fwrite :: Handle -> Arr a -> Run () Source #

fread :: Handle -> Run (Arr a) Source #

type SizeSpec (Arr a) Source # 
type HaskellRep (Arr a) Source # 
type HaskellRep (Arr a) = [Internal a]

type DArr a = Arr (Data a) Source #

Array specialized to Data elements

data IArr a Source #

Immutable array

Instances

MonadComp m => Manifestable2 m (Manifest2 a) a Source #

manifest2 and manifestFresh2 are no-ops. manifestStore2 does a proper arrCopy.

MonadComp m => Manifestable m (Manifest a) a Source #

manifest and manifestFresh are no-ops. manifestStore does a proper arrCopy.

Methods

manifest :: Arr a -> Manifest a -> m (Manifest a) Source #

manifestFresh :: Manifest a -> m (Manifest a) Source #

manifestStore :: Arr a -> Manifest a -> m () Source #

(Syntax a, MonadComp m) => Seqy m (Manifest a) a Source # 

Methods

toSeq :: Manifest a -> Seq m a Source #

(Syntax a, MonadComp m) => Pushy2 m (Manifest2 a) a Source # 

Methods

toPush2 :: Manifest2 a -> Push2 m a Source #

(Syntax a, MonadComp m) => Pushy2 m (Manifest a) a Source #

Convert to a Push2 with a single row

Methods

toPush2 :: Manifest a -> Push2 m a Source #

(Syntax a, MonadComp m) => Pushy m (Manifest a) a Source # 

Methods

toPush :: Manifest a -> Push m a Source #

Slicable (IArr a) Source # 

Methods

slice :: Data Index -> Data Length -> IArr a -> IArr a Source #

Finite (IArr a) Source # 

Methods

length :: IArr a -> Data Length Source #

Syntax a => Indexed (IArr a) Source # 

Associated Types

type IndexedElem (IArr a) :: * Source #

Methods

(!) :: IArr a -> Data Index -> IndexedElem (IArr a) Source #

(MarshalHaskell (Internal a), MarshalFeld a, Syntax a) => MarshalFeld (IArr a) Source # 

Associated Types

type HaskellRep (IArr a) :: * Source #

Methods

fwrite :: Handle -> IArr a -> Run () Source #

fread :: Handle -> Run (IArr a) Source #

Syntax a => Storable (Manifest2 a) Source # 
Syntax a => Storable (Manifest a) Source # 
ViewManifest2 (Manifest2 a) a Source # 
ViewManifest (Manifest a) a Source # 
Syntax a => Pully2 (Manifest a) a Source #

Convert to a Pull2 with a single row

Methods

toPull2 :: Manifest a -> Pull2 a Source #

type IndexedElem (IArr a) Source # 
type IndexedElem (IArr a) = a
type SizeSpec (IArr a) Source # 
type HaskellRep (IArr a) Source # 
type HaskellRep (IArr a) = [Internal a]
type StoreRep (Manifest2 a) Source # 
type StoreRep (Manifest a) Source # 
type StoreRep (Manifest a) = (DRef Length, Arr a)
type StoreSize (Manifest2 a) Source # 
type StoreSize (Manifest a) Source # 

type DIArr a = IArr (Data a) Source #

Immutable array specialized to Data elements

unsafeEqArrIArr :: Arr a -> IArr a -> Bool Source #

Check if an Arr and and IArr use the same physical array. The length and offset are ignored. This operation may give false negatives, but never false positives. Whether or not false negatives occur may also depend on the interpretation of the program.

Due to this unreliability, the function should only be used to affect the non-functional properties of a program (e.g. to avoid unnecessary array copying).

Pure expressions

data AssertionLabel Source #

Assertion labels

Constructors

InternalAssertion

Internal assertion to guarantee meaningful results

LibraryAssertion String

Assertion related to a specific library

UserAssertion String

Assertion in user code. The default label for user assertions is UserAssertion ""

onlyUserAssertions :: Selection AssertionLabel Source #

A selection that includes all labels defined as UserAssertion

data ForLoop sig where Source #

For loop

Constructors

ForLoop :: Type st => ForLoop (Length :-> (st :-> ((Index -> st -> st) :-> Full st))) 

Instances

Eval ForLoop Source # 

Methods

evalSym :: ForLoop sig -> Denotation sig #

Equality ForLoop Source # 

Methods

equal :: ForLoop a -> ForLoop b -> Bool #

hash :: ForLoop a -> Hash #

Render ForLoop Source # 

Methods

renderSym :: ForLoop sig -> String #

renderArgs :: [String] -> ForLoop sig -> String #

StringTree ForLoop Source # 
Symbol ForLoop Source # 

Methods

symSig :: ForLoop sig -> SigRep sig #

EvalEnv ForLoop env Source # 

Methods

compileSym :: proxy env -> ForLoop sig -> DenotationM (Reader env) sig #

data Unsafe sig where Source #

Interaction with the IO layer

Constructors

UnsafePerform :: Comp (Data a) -> Unsafe (Full a) 

Instances

Eval Unsafe Source # 

Methods

evalSym :: Unsafe sig -> Denotation sig #

Equality Unsafe Source #

equal always returns False

Methods

equal :: Unsafe a -> Unsafe b -> Bool #

hash :: Unsafe a -> Hash #

Render Unsafe Source # 

Methods

renderSym :: Unsafe sig -> String #

renderArgs :: [String] -> Unsafe sig -> String #

StringTree Unsafe Source # 
Symbol Unsafe Source # 

Methods

symSig :: Unsafe sig -> SigRep sig #

EvalEnv Unsafe env Source # 

Methods

compileSym :: proxy env -> Unsafe sig -> DenotationM (Reader env) sig #

newtype Data a Source #

Constructors

Data 

Fields

Instances

FreeExp Data Source # 

Associated Types

type FreePred (Data :: * -> *) :: * -> Constraint #

Methods

constExp :: FreePred Data a => a -> Data a #

varExp :: FreePred Data a => VarId -> Data a #

EvalExp Data Source # 

Methods

evalExp :: Data a -> a #

Syntactic (Data a) Source #

Declaring Data as syntactic sugar

Associated Types

type Domain (Data a) :: * -> * #

type Internal (Data a) :: * #

Methods

desugar :: Data a -> ASTF (Domain (Data a)) (Internal (Data a)) #

sugar :: ASTF (Domain (Data a)) (Internal (Data a)) -> Data a #

PrimType' a => BulkTransferable (Data a) Source # 

Associated Types

type ContainerType (Data a) :: * Source #

PrimType' a => Transferable (Data a) Source # 
MarshalFeld (Data Double) Source # 

Associated Types

type HaskellRep (Data Double) :: * Source #

MarshalFeld (Data Float) Source # 

Associated Types

type HaskellRep (Data Float) :: * Source #

MarshalFeld (Data Int8) Source # 

Associated Types

type HaskellRep (Data Int8) :: * Source #

MarshalFeld (Data Int16) Source # 

Associated Types

type HaskellRep (Data Int16) :: * Source #

MarshalFeld (Data Int32) Source # 

Associated Types

type HaskellRep (Data Int32) :: * Source #

MarshalFeld (Data Int64) Source # 

Associated Types

type HaskellRep (Data Int64) :: * Source #

MarshalFeld (Data Word8) Source # 

Associated Types

type HaskellRep (Data Word8) :: * Source #

MarshalFeld (Data Word16) Source # 

Associated Types

type HaskellRep (Data Word16) :: * Source #

MarshalFeld (Data Word32) Source # 

Associated Types

type HaskellRep (Data Word32) :: * Source #

MarshalFeld (Data Word64) Source # 

Associated Types

type HaskellRep (Data Word64) :: * Source #

MarshalFeld (Data (Complex Double)) Source # 

Associated Types

type HaskellRep (Data (Complex Double)) :: * Source #

MarshalFeld (Data (Complex Float)) Source # 

Associated Types

type HaskellRep (Data (Complex Float)) :: * Source #

Type a => Storable (Data a) Source # 

Associated Types

type StoreRep (Data a) :: * Source #

type StoreSize (Data a) :: * Source #

Methods

newStoreRep :: MonadComp m => proxy (Data a) -> StoreSize (Data a) -> m (StoreRep (Data a)) Source #

initStoreRep :: MonadComp m => Data a -> m (StoreRep (Data a)) Source #

readStoreRep :: MonadComp m => StoreRep (Data a) -> m (Data a) Source #

unsafeFreezeStoreRep :: MonadComp m => StoreRep (Data a) -> m (Data a) Source #

writeStoreRep :: MonadComp m => StoreRep (Data a) -> Data a -> m () Source #

Type a => Forcible (Data a) Source # 

Associated Types

type ValueRep (Data a) :: * Source #

Methods

toValue :: MonadComp m => Data a -> m (ValueRep (Data a)) Source #

fromValue :: ValueRep (Data a) -> Data a Source #

(Formattable a, PrimType a, PrintfType r) => PrintfType (Data a -> r) Source # 

Methods

fprf :: Handle -> String -> [PrintfArg Data] -> Data a -> r Source #

Syntactic (Struct PrimType' Data a) Source # 
type FreePred Data Source # 
type Internal (Data a) Source # 
type Internal (Data a) = a
type Domain (Data a) Source # 
type ContainerType (Data a) Source # 
type ContainerType (Data a) = DArr a
type SizeSpec (Data a) Source # 
type HaskellRep (Data Double) Source # 
type HaskellRep (Data Float) Source # 
type HaskellRep (Data Int8) Source # 
type HaskellRep (Data Int16) Source # 
type HaskellRep (Data Int32) Source # 
type HaskellRep (Data Int64) Source # 
type HaskellRep (Data Word8) Source # 
type HaskellRep (Data Word16) Source # 
type HaskellRep (Data Word32) Source # 
type HaskellRep (Data Word64) Source # 
type HaskellRep (Data (Complex Double)) Source # 
type HaskellRep (Data (Complex Float)) Source # 
type StoreRep (Data a) Source # 
type StoreRep (Data a) = DRef a
type StoreSize (Data a) Source # 
type StoreSize (Data a) = ()
type ValueRep (Data a) Source # 
type ValueRep (Data a) = Data a
type Internal (Struct PrimType' Data a) Source # 
type Domain (Struct PrimType' Data a) Source # 

class (Syntactic a, Domain a ~ FeldDomain, Type (Internal a)) => Syntax a Source #

Specialization of the Syntactic class for the Feldspar domain

Instances

(Syntactic a, (~) (* -> *) (Domain a) FeldDomain, Type (Internal a)) => Syntax a Source # 

sugarSymFeld :: (Signature sig, fi ~ SmartFun FeldDomain sig, sig ~ SmartSig fi, FeldDomain ~ SmartSym fi, SyntacticN f fi, sub :<: FeldConstructs, Type (DenResult sig)) => sub sig -> f Source #

Make a smart constructor for a symbol

sugarSymFeldPrim :: (Signature sig, fi ~ SmartFun FeldDomain sig, sig ~ SmartSig fi, FeldDomain ~ SmartSym fi, SyntacticN f fi, sub :<: FeldConstructs, PrimType' (DenResult sig)) => sub sig -> f Source #

Make a smart constructor for a symbol

eval :: (Syntactic a, Domain a ~ FeldDomain) => a -> Internal a Source #

Evaluate a closed expression

Monadic computations

data AssertCMD fs a where Source #

Constructors

Assert :: AssertionLabel -> exp Bool -> String -> AssertCMD (Param3 prog exp pred) () 

Instances

HFunctor * k1 (* -> *, (k, *)) (AssertCMD (k1 -> *) k) Source # 

Methods

hfmap :: (forall b. f b -> g b) -> h ((k1 -> *, k2) f fs) a -> h ((k1 -> *, k2) g fs) a #

HBifunctor * * (k, *) (AssertCMD (* -> *) k) Source # 

Methods

hbimap :: (Functor f, Functor g) => (forall b. f b -> g b) -> (forall b. i b -> j b) -> h ((* -> *, (k1 -> *, k2)) f ((k1 -> *, k2) i fs)) a -> h ((* -> *, (k1 -> *, k2)) g ((k1 -> *, k2) j fs)) a #

(:<:) * (* -> *, (* -> *, (* -> Constraint, *))) ControlCMD instr => Reexpressible * (* -> Constraint, *) (AssertCMD (* -> *) (* -> Constraint)) instr Env # 

Methods

reexpressInstrEnv :: Monad m => (forall b. exp1 b -> ReaderT * env (ProgramT (AssertCMD (* -> *) (* -> Constraint) -> *, instr) instr ((AssertCMD (* -> *) (* -> Constraint) -> *, instr) exp2 fs) m) (exp2 b)) -> Env ((* -> *, (AssertCMD (* -> *) (* -> Constraint) -> *, instr)) (ReaderT * env (ProgramT (AssertCMD (* -> *) (* -> Constraint) -> *, instr) instr ((AssertCMD (* -> *) (* -> Constraint) -> *, instr) exp2 fs) m)) ((AssertCMD (* -> *) (* -> Constraint) -> *, instr) exp1 fs)) a -> ReaderT * env (ProgramT (AssertCMD (* -> *) (* -> Constraint) -> *, instr) instr ((AssertCMD (* -> *) (* -> Constraint) -> *, instr) exp2 fs) m) a #

InterpBi * (* -> Constraint, *) (AssertCMD (* -> *) (* -> Constraint)) IO (Param1 (* -> Constraint) PrimType') Source # 

Methods

interpBi :: Param1 (* -> Constraint) PrimType' ((AssertCMD (* -> *) (* -> Constraint) -> *, (AssertCMD (* -> *) (* -> Constraint) -> *, IO)) m ((AssertCMD (* -> *) (* -> Constraint) -> *, IO) m fs)) a -> m a #

newtype Comp a Source #

Monad for computational effects: mutable data structures and control flow

Constructors

Comp 

Instances

Monad Comp Source # 

Methods

(>>=) :: Comp a -> (a -> Comp b) -> Comp b #

(>>) :: Comp a -> Comp b -> Comp b #

return :: a -> Comp a #

fail :: String -> Comp a #

Functor Comp Source # 

Methods

fmap :: (a -> b) -> Comp a -> Comp b #

(<$) :: a -> Comp b -> Comp a #

Applicative Comp Source # 

Methods

pure :: a -> Comp a #

(<*>) :: Comp (a -> b) -> Comp a -> Comp b #

(*>) :: Comp a -> Comp b -> Comp b #

(<*) :: Comp a -> Comp b -> Comp a #

MonadComp Comp Source # 

Methods

liftComp :: Comp a -> Comp a Source #

iff :: Data Bool -> Comp () -> Comp () -> Comp () Source #

for :: (Integral n, PrimType n) => IxRange (Data n) -> (Data n -> Comp ()) -> Comp () Source #

while :: Comp (Data Bool) -> Comp () -> Comp () Source #

MonadRun Comp Source # 

Methods

liftRun :: Comp a -> Run a Source #

Syntax a => Storable (Push Comp a) Source # 

Associated Types

type StoreRep (Push Comp a) :: * Source #

type StoreSize (Push Comp a) :: * Source #

type StoreRep (Push Comp a) Source # 
type StoreRep (Push Comp a) = (DRef Length, Arr a)
type StoreSize (Push Comp a) Source #