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

Stabilityexperimental
Maintainerconal@conal.net

Shady.Language.Type

Contents

Description

Types

Synopsis

Type values

data ScalarT whereSource

Constructors

Bool :: ScalarT Bool 
Int :: ScalarT Int 
Float :: ScalarT Float 

data VectorT n a Source

Constructors

VectorT (Nat n) (ScalarT a) 

Instances

data Type whereSource

Extended types. Vector types, samplers, unit, pairing, and functions.

Constructors

VecT :: (IsNat n, IsScalar a) => VectorT n a -> Type (Vec n a) 
SamplerT :: IsNat n => Nat n -> Type (Sampler n) 
UnitT :: Type () 
:*: :: (HasType a, HasType b) => Type a -> Type b -> Type (a, b) 
:->: :: (HasType a, HasType b) => Type a -> Type b -> Type (a -> b) 

Instances

type TextureId = IntSource

Encoding of texture ids in values. I'm using Int instead of GLuint here to avoid depending on OpenGL in this module & package.

data Sampler n Source

An n-dimensional GLSL sampler.

Constructors

Sampler 

Instances

Generating type values

class (Storable a, Typeable a, Show a) => IsScalar a whereSource

Has scalar type

class Show t => HasType t whereSource

Known types

Methods

typeT :: Type tSource

Instances

HasType () 
IsNat n => HasType (Sampler n) 
(HasType a, HasType b) => HasType (a -> b) 
(HasType a, HasType b) => HasType (a, b) 
(IsNat n, IsScalar a) => HasType (Vec n a) 

typeOf :: HasType a => a -> Type aSource

Reify a type

typeOf1 :: HasType a => f a -> Type aSource

Reify a type argument

typeOf2 :: HasType a => g (f a) -> Type aSource

Reify a type argument's argument

compatible :: (HasType a, HasType b) => a -> b -> Maybe (a :=: b)Source

Do two values have the same type. If so, return a proof.

compatible1 :: (HasType a, HasType b) => f a -> g b -> Maybe (a :=: b)Source

Do two values have the same argument type. If so, return a proof.

data IsVec whereSource

Demonstration that a type argument is a vector type.

Constructors

IsVec :: (IsNat n, IsScalar a) => IsVec (Vec n a) 

checkVec :: forall t. HasType t => Maybe (IsVec t)Source

Check for a vector type

checkVec' :: forall f t. HasType t => f t -> Maybe (IsVec t)Source

Convenient wrapper around checkVec. Ignores argument.

Type equality

data ($a) :=: ($b) where

Type equality proof

Constructors

Refl :: :=: a a 

ptyEq :: ScalarT a -> ScalarT b -> Maybe (a :=: b)Source

Try to prove equality of primitive types

vtyEq :: VectorT m a -> VectorT n b -> Maybe (Vec m a :=: Vec n b)Source

Try to prove equality of types

tyEq :: Type c -> Type c' -> Maybe (c :=: c')Source

Try to prove equality of types

(=:=) :: forall f a b. (HasType a, HasType b, SynEq f) => f a -> f b -> Maybe (a :=: b)Source

Yields Just Refl if type-compatible and equal. Otherwise Nothing.

(===) :: forall f a b. (HasType a, HasType b, SynEq f) => f a -> f b -> BoolSource

Same type and syntactically equal

Vector operations

Convenient type synonyms

type R = FloatSource

type R1 = One RSource

Convenient short-hand

type R2 = Two RSource

Convenient short-hand

type R3 = Three RSource

Convenient short-hand

type R4 = Four RSource

Convenient short-hand

type B1 = One BoolSource

Single boolean

type Pred1 a = a -> B1Source

Unary predicate

type Pred2 a = a -> Pred1 aSource

Binary predicate

Notions of equality

class SynEq f whereSource

Syntactic equality. Requires same argument type.

Methods

(=-=) :: HasType c => f c -> f c -> BoolSource

Instances

SynEq Op 
SynEq E 
SynEq V 
Eq x => SynEq (Const x) 

class SynEq2 f whereSource

Higher-order variant of SynEq. Can be defined via '(=-=)', or vice versa.

Methods

(=--=) :: (SynEq v, HasType c) => f v c -> f v c -> BoolSource

Pairing and unit

class PairF f whereSource

Methods

(#) :: (HasType a, HasType b) => f a -> f b -> f (a :# b)Source

Instances

type :# a b = (a, b)Source

Syntactic alternative for pairing. Convenient for right-associative infix use.

class UnitF f whereSource

Methods

unit :: f ()Source

Instances

UnitF E 
UnitF (Glom f) 

Re-export

module Shady.Vec