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

Stabilityexperimental
Maintainerconal@conal.net

Text.PrettyPrint.Leijen.DocExpr

Contents

Description

Variation of Twan van Laarhoven's simple-reflect http://hackage.haskell.org/cgi-bin/hackage-scripts/package/simple-reflect

Differences from Twan's version: + Generates pretty-printings instead of strings + No evaluation + Removed overloadings that disagree with semantic versions (e.g., '(==)') + A few stylistic tweaks

Synopsis

Construction

data Expr Source

A reflected expression

Constructors

Expr 

Fields

edoc :: Int -> Doc

Generate doc, given contextual precedence level

class FromExpr a whereSource

Conversion from Expr to other types

Methods

fromExpr :: Expr -> aSource

Instances

FromExpr Expr 
(PrettyPrec a, FromExpr b) => FromExpr (a -> b) 

var :: String -> ExprSource

A variable with the given name

fun :: FromExpr a => String -> aSource

A generic, overloaded, function variable

($$) :: Expr -> Expr -> ExprSource

Function application

data Associativity Source

This data type specifies the associativity of operators: left, right or none.

Constructors

InfixL 
Infix 
InfixR 

Instances

op :: Associativity -> Int -> String -> Expr -> Expr -> ExprSource

An infix operator with the given associativity, precedence and name

lambdaX :: String -> Expr -> ExprSource

A lambda expression

letX :: String -> Expr -> Expr -> ExprSource

A "let" expression

tupleX :: [Expr] -> ExprSource

A tuple expression

ccall :: String -> [Expr] -> ExprSource

C-style call

dotX :: String -> Expr -> ExprSource

e.foo

onDoc :: (Doc -> Doc) -> Expr -> ExprSource

Altering the generated Doc

class Show a => HasExpr a whereSource

Methods

expr :: a -> ExprSource

Instances

HasExpr Bool 
HasExpr Char 
HasExpr Double 
HasExpr Float 
HasExpr Int 
HasExpr Integer 
HasExpr () 
HasExpr Doc 
HasExpr Expr 
(Show a, PrettyPrec a) => HasExpr [a] 
Integral a => HasExpr (Ratio a) 
(Show a, PrettyPrec a) => HasExpr (Maybe a) 
HasExpr a => HasExpr (Complex a) 
HasExpr (Type t) 
HasExpr (ScalarT a) 
HasExpr (E a) 
HasExpr a => HasExpr (V a) 
(Show a, Show b, Pretty a, Pretty b) => HasExpr (a, b) 
(IsNat n, IsScalar a, Show a) => HasExpr (Vec n a) 
HasExpr (VectorT n a) 
(HasExpr a, HasExprU f) => HasExpr (Glom f a) 
(Show a, Show b, Show c, Pretty a, Pretty b, Pretty c) => HasExpr (a, b, c) 

class HasExprU h whereSource

Methods

exprU :: forall a. h a -> ExprSource

prettyExpr :: HasExpr a => Int -> a -> DocSource

Convenient for defining PrettyPrec when we have a HasExpr.

Utility

docParen :: Bool -> Doc -> DocSource

Variant of showParen