shady-gen-0.5.1: Functional GPU programming - DSEL & compiler

Stabilityexperimental
Maintainerconal@conal.net

Shady.Language.Exp

Contents

Description

Expressions.

Synopsis

Variables

type Id = StringSource

Variable name

data V a Source

Typed variables

Constructors

V 

Fields

varName :: Id
 
varType :: Type a
 

Instances

HasExprU V 
SynEq V 
Show (V a) 
HasExpr a => Pretty (V a) 
HasExpr a => PrettyPrec (V a) 
HasExpr a => HasExpr (V a) 
ToE (Pat a) 

var :: HasType a => Id -> V aSource

Make a variable, inferring the type from context.

Patterns

type Pat = Glom VSource

Variable patterns

patT :: Pat a -> Type aSource

The type of a pattern

pat :: HasType a => String -> Pat aSource

Make a variable pattern, inferring the type from context.

Type paths

data TPath Source

Type path

emptyP :: TPathSource

Empty type path

sndP :: TPath -> TPathSource

Extend a type path

namePath :: String -> TPath -> StringSource

Augment a variable name with a type path

Expressions

data E whereSource

Simple expressions (no Let). Statically typed. Constructors for operator/constant (Op), variable (Var), application ('(:^)'), and abstraction (Lam).

Constructors

Op :: Op a -> E a 
Var :: V a -> E a 
:^ :: HasType a => E (a -> b) -> E a -> E b 
Lam :: HasType a => V a -> E b -> E (a -> b) 

Instances

UnitF E 
PairF E 
SynEq E 
(IsNat n, IsScalar a, Show a) => IfB BoolE (VecE n a) 
Enum a => Enum (E a) 
Eq (E a) 
(IsNat n, IsScalar b, Floating b) => Floating (E (Vec n b)) 
(IsNat n, IsScalar b, Fractional b) => Fractional (E (Vec n b)) 
(IsNat n, IsScalar b, Integral b) => Integral (E (Vec n b)) 
(IsNat n, IsScalar a, Num a) => Num (E (Vec n a)) 
(IsNat n, IsScalar a, Ord a, Show a) => Ord (E (Vec n a)) 
(IsNat n, IsScalar a, Ord a, Num a) => Real (E (Vec n a)) 
(IsNat n, IsScalar b, RealFrac b) => RealFrac (E (Vec n b)) 
Show (E a) 
(IsNat n, IsScalar a, Num a) => VectorSpace (E (Vec n a)) 
IsNat n => InnerSpace (E (Vec n R)) 
(IsNat n, IsScalar a, Num a) => AdditiveGroup (E (Vec n a)) 
Pretty (E a) 
(IsNat n, IsScalar a, FMod a) => FMod (E (Vec n a)) 
(IsNat n, IsScalar a, FMod a, RealFrac a) => Frac (E (Vec n a)) 
PrettyPrec (E a) 
HasExpr (E a) 
(Show a, IsScalar a) => FromE (ComplexE a) 
FromE (E a) 
(Show a, IsScalar a) => ToE (ComplexE a) 
ToE (E a) 
IsNat n => Boolean (VecE n Bool) 
(IsNat n, IsScalar a, Eq a, Show a) => EqB (VecE n Bool) (VecE n a) 
(IsNat n, IsScalar a, Ord a, Show a) => OrdB (VecE n Bool) (VecE n a) 

type :=> a b = E a -> bSource

Function from expressions. Nestable.

type :=>* a b = a :=> E bSource

Expression to expression. Ends a chain of '(:=>)'

n-ary operator application

op1 :: (HasType a, HasType b) => Op (a -> b) -> a :=>* bSource

Convenient operator application

op2 :: (HasType a, HasType b, HasType c) => Op (a -> b -> c) -> a :=> (b :=>* c)Source

Convenient operator application

op3 :: (HasType a, HasType b, HasType c, HasType d) => Op (a -> b -> c -> d) -> a :=> (b :=> (c :=>* d))Source

Convenient operator application

op4 :: (HasType a, HasType b, HasType c, HasType d, HasType e) => Op (a -> b -> c -> d -> e) -> a :=> (b :=> (c :=> (d :=>* e)))Source

Convenient operator application

Optimizing expression-builders

pureE :: Show a => a -> E aSource

Literal expression

fmapE :: (HasType a, HasType b) => Op (a -> b) -> a :=>* bSource

Apply a unary operator, with constant-folding and simplifications

liftE2 :: (HasType a, HasType b, HasType c) => Op (a -> b -> c) -> a :=> (b :=>* c)Source

Apply a binary operator, with constant-folding and simplifications

liftE3 :: (HasType a, HasType b, HasType c, HasType d) => Op (a -> b -> c -> d) -> a :=> (b :=> (c :=>* d))Source

Apply a ternary operator, with constant-folding and simplifications

liftE4 :: (HasType a, HasType b, HasType c, HasType d, HasType e) => Op (a -> b -> c -> d -> e) -> a :=> (b :=> (c :=> (d :=>* e)))Source

Apply an quaternary operator, with constant-folding and simplifications

Operations

notE :: IsNat n => Vec n Bool :=>* Vec n BoolSource

Transitional synonym for notB

(==^) :: (IsNat n, IsScalar a, Eq a, Show a) => Vec n a :=> (Vec n a :=>* B1)Source

Vector equality, resulting in a single Bool. See also '(==*)'.

(/=^) :: (IsNat n, IsScalar a, Eq a, Show a) => Vec n a :=> (Vec n a :=>* B1)Source

Vector inequality, resulting in a single Bool. See also '(/=*)'.

allV :: IsNat n => Vec n Bool :=>* B1Source

Are all of the Bools true?

anyV :: IsNat n => Vec n Bool :=>* B1Source

Is all of the Bools true?

type SamplerE n = E (Sampler n)Source

texture :: IsNat n => Sampler n :=> (Vec n R :=>* R4)Source

Texturing

lit :: Show a => a -> E aSource

Literal value

type FloatE = E R1Source

Float expression

type R1E = E R1Source

type R2E = E R2Source

type R3E = E R3Source

type R4E = E R4Source

type VecE n a = E (Vec n a)Source

Expression vector

vec2 :: (IsScalar a, Show a) => One a :=> (One a :=>* Two a)Source

vec3 :: (IsScalar a, Show a) => One a :=> (One a :=> (One a :=>* Three a))Source

vec4 :: (IsScalar a, Show a) => One a :=> (One a :=> (One a :=> (One a :=>* Four a)))Source

un2 :: IsScalar a => Two a :=> (E (One a), E (One a))Source

un3 :: IsScalar a => Three a :=> (E (One a), E (One a), E (One a))Source

un4 :: IsScalar a => Four a :=> (E (One a), E (One a), E (One a), E (One a))Source

getX :: (IsNat n, IsScalar a, Show a) => Vec (S n) a :=>* One aSource

Extract X component

getY :: (IsNat n, IsScalar a, Show a) => Vec (S (S n)) a :=>* One aSource

Extract Y component

getZ :: (IsNat n, IsScalar a, Show a) => Vec (S (S (S n))) a :=>* One aSource

Extract Z component

getW :: (IsNat n, IsScalar a, Show a) => Vec (S (S (S (S n)))) a :=>* One aSource

Extract W component

get :: (IsNat n, IsScalar a, Show a) => Index n -> Vec n a :=>* One aSource

Extract vector component

(<+>) :: (IsNat m, IsNat n, IsNat (m :+: n), IsScalar a, Show a) => Vec m a :=> (Vec n a :=>* Vec (m :+: n) a)Source

Concatenation of vectors

unitE :: E ()Source

Expression-lifted '()'

pairE :: (HasType a, HasType b) => E a -> E b -> E (a, b)Source

Expression-lifted '(,)'

fstE :: (HasType a, HasType b) => Show a => E (a, b) -> E aSource

Expression-lifted fst

sndE :: (HasType a, HasType b) => Show b => E (a, b) -> E bSource

Expression-lifted snd

unPairE :: (HasType a, HasType b) => E (a, b) -> (E a, E b)Source

Unpack a pair

uniform :: (IsNat n, IsScalar a, Show a) => (E (Vec n a) -> b) -> E (One a) -> bSource

Uniform version of a function on vectors

uniformV :: (IsNat n, IsScalar a, Show a) => One a :=>* Vec n aSource

Uniform vector

type ComplexE a = Complex (E (One a))Source

Complex-valued expressions

Conversion to expressions

class ToE w whereSource

Value convertible to an expression

Associated Types

type ExpT w Source

Methods

toEN :: w -> NameM (E (ExpT w))Source

Instances

ToE () 
(Show a, IsScalar a) => ToE (ComplexE a) 
ToE (E a) 
ToE (Pat a) 
(FromE u, ToE v, HasType (ExpT u)) => ToE (u -> v) 
(ToE u, Show (ExpT u), HasType (ExpT u), ToE v, Show (ExpT v), HasType (ExpT v)) => ToE (u, v) 
(ToE u, HasType (ExpT u), ToE v, HasType (ExpT v), ToE w, HasType (ExpT w)) => ToE (u, v, w) 

toE :: ToE w => w -> E (ExpT w)Source

Convert to an expression, using fresh name supply

class ToE w => FromE w whereSource

Value convertible from an expression

Methods

fromE :: E (ExpT w) -> wSource

Instances

FromE () 
(Show a, IsScalar a) => FromE (ComplexE a) 
FromE (E a) 
(FromE u, HasType (ExpT u), FromE v, HasType (ExpT v)) => FromE (u, v) 
(FromE u, HasType (ExpT u), FromE v, HasType (ExpT v), FromE w, HasType (ExpT w)) => FromE (u, v, w) 

toFromE :: (FromE v, FromE w) => (v -> w) -> E (ExpT v) -> E (ExpT w)Source

Construct an E transformer from an ExpT transformer

patE :: Pat a -> E aSource

Turn a pattern into an expression.

Temporary

letE :: (HasType a, HasType b) => V a -> E a -> E b -> E bSource

Short-hand for beta-redex