drasil-gool-0.1.1.0: A framework for code and document generation for scientific software - GOOL SubPackage
Safe HaskellNone
LanguageGHC2024

Drasil.Shared.LanguageRenderer.Constructors

Description

Generic constructors and smart constructors to be used in renderers

Synopsis

Documentation

mkStmt :: forall {k} r (stmt :: k). RenderStatement r stmt => Doc -> MS (r stmt) Source #

Constructs a statement terminated by a semi-colon

mkStmtNoEnd :: forall {k} r (stmt :: k). RenderStatement r stmt => Doc -> MS (r stmt) Source #

Constructs a statement without a termination character

mkStateVal :: forall {k} r (var :: k) (val :: k) (typ :: k). RenderValue r var val typ => VS (r typ) -> Doc -> VS (r val) Source #

Constructs a value in a stateful context

mkVal :: forall {k} r (var :: k) (val :: k) (typ :: k). RenderValue r var val typ => r typ -> Doc -> VS (r val) Source #

Constructs a value in a non-stateful context

mkStateVar :: forall {k} r (var :: k) (typ :: k). RenderVariable r var typ => String -> VS (r typ) -> Doc -> VS (r var) Source #

Constructs an instance-level variable in a stateful context

mkVar :: forall {k} r (var :: k) (typ :: k). RenderVariable r var typ => String -> r typ -> Doc -> VS (r var) Source #

Constructs an instance-level variable in a non-stateful context

mkClassVar :: forall {k} r (var :: k) (typ :: k). RenderVariable r var typ => String -> VS (r typ) -> Doc -> VS (r var) Source #

Constructs a classLevel variable in a stateful context

type VSOp (r :: Type -> Type) = VS (r OpData) Source #

mkOp :: Monad r => Int -> Doc -> VSOp r Source #

Construct an operator with given precedence and rendering

unOpPrec :: Monad r => String -> VSOp r Source #

Construct an operator with typical unary-operator precedence

compEqualPrec :: Monad r => String -> VSOp r Source #

Construct an operator with equality-comparison-level precedence

compPrec :: Monad r => String -> VSOp r Source #

Construct an operator with comparison-level precedence

addPrec :: Monad r => String -> VSOp r Source #

Construct an operator with addition-level precedence

multPrec :: Monad r => String -> VSOp r Source #

Construct an operator with multiplication-level precedence

powerPrec :: Monad r => String -> VSOp r Source #

Construct an operator with exponentiation-level precedence

andPrec :: Monad r => String -> VSOp r Source #

Construct an operator with conjunction-level precedence

orPrec :: Monad r => String -> VSOp r Source #

Construct an operator with disjunction-level precedence

unExpr :: (OpElim r, RenderValue r var val typ, ValueElim r val, ValueSym r val typ) => VSUnOp r -> VS (r val) -> VS (r val) Source #

Constructs a unary expression like ln(v), for some operator ln and value v

unExpr' :: (OpElim r, RenderValue r var val typ, ValueElim r val, ValueSym r val typ) => VSUnOp r -> VS (r val) -> VS (r val) Source #

Constructs a unary expression like -v, for some operator - and value v

unExprNumDbl :: (OpElim r, RenderValue r var val typ, TypeSym r typ, TypeElim r typ, ValueElim r val, ValueSym r val typ) => VSUnOp r -> VS (r val) -> VS (r val) Source #

To be used in languages where the unary operator returns a double. If the value passed to the operator is a float, this function preserves that type by casting the result to a float.

typeUnExpr :: (OpElim r, RenderValue r var val typ, ValueElim r val) => VSUnOp r -> VS (r typ) -> VS (r val) -> VS (r val) Source #

To be used when the type of the value is different from the type of the resulting expression. The type of the result is passed as a parameter.

binExpr :: (OpElim r, RenderValue r var val typ, TypeElim r typ, ValueElim r val, ValueSym r val typ) => VSBinOp r -> VS (r val) -> VS (r val) -> VS (r val) Source #

Constructs binary expressions like v + w, for some operator + and values v and w, parenthesizing v and w if needed.

binExpr' :: (OpElim r, RenderValue r var val typ, TypeElim r typ, ValueElim r val, ValueSym r val typ) => VSBinOp r -> VS (r val) -> VS (r val) -> VS (r val) Source #

Constructs binary expressions like pow(v,w), for some operator pow and values v and w

binExprNumDbl' :: (OpElim r, RenderValue r var val typ, TypeSym r typ, TypeElim r typ, ValueElim r val, ValueSym r val typ) => VSBinOp r -> VS (r val) -> VS (r val) -> VS (r val) Source #

To be used in languages where the binary operator returns a double. If either value passed to the operator is a float, this function preserves that type by casting the result to a float.

typeBinExpr :: (OpElim r, RenderValue r var val typ, ValueElim r val) => VSBinOp r -> VS (r typ) -> VS (r val) -> VS (r val) -> VS (r val) Source #

To be used when the types of the values are different from the type of the resulting expression. The type of the result is passed as a parameter.