{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleContexts #-}
module Drasil.GProc.LanguageRenderer.MatlabRenderer (
MatlabCode(..), mlName, mlVersion
) where
import Drasil.Shared.InterfaceCommon (Label, Value, SValue, Variable, SVariable,
getCodeType, UnRepr(..), SharedProg, SharedStatement, Body, BodySym(..),
BlockSym(..), TypeSym(..), TypeElim(..), VariableSym(..), VariableElim(..),
ValueSym(..), Argument(..), Literal(..), MathConstant(..), VariableValue(..),
CommandLineArgs(..), NumericExpression(..), BooleanExpression(..),
Comparison(..), ValueExpression(..), IndexTranslator(..), Reference(..),
Array(..), List(..), Set(..), NativeVector(..), InternalList(..),
StatementSym(..), AssignStatement(..), DeclStatement(..), IOStatement(..),
StringStatement(..), FunctionSym, FuncAppStatement(..), CommentStatement(..),
ControlStatement(..), switchAsIf, VisibilitySym(..), ScopeSym(..),
ParameterSym(..), BinderSym(..), BinderElim(..), MethodSym(..), funcApp, (&=))
import Drasil.GProc.InterfaceProc (ProcProg, ProgramSym(..),
FileSym(..), ModuleSym(..))
import Drasil.Shared.RendererClassesCommon (CommonRenderSym, ImportSym(..),
RenderBody(..), BodyElim, RenderBlock(..), BlockElim, RenderType(..),
UnaryOpSym(..), BinaryOpSym(..), OpElim(uOpPrec, bOpPrec), RenderVariable(..),
InternalVarElim(variableBind), RenderValue(..), ValueElim(..),
InternalListFunc(..), RenderFunction(..), FunctionElim(functionType),
InternalAssignStmt(..), InternalIOStmt(..), InternalControlStmt(..),
RenderStatement(..), StatementElim(statementTerm), RenderVisibility(..),
VisibilityElim, MethodTypeSym(..), RenderParam(..),
ParamElim(parameterName, parameterType), RenderMethod(..), MethodElim,
BlockCommentSym(..), BlockCommentElim, ScopeElim(..), InternalBinderElim(..))
import qualified Drasil.Shared.RendererClassesCommon as RC (body, block, uOp,
bOp, variable, value, function, statement, visibility, parameter, method,
blockComment')
import Drasil.GProc.RendererClassesProc (ProcRenderSym, RenderFile(..),
RenderMod(..), ModuleElim, ProcRenderMethod(..))
import qualified Drasil.GProc.LanguageRenderer.AbstractProc as A (fileDoc,
docMod, fileFromData, buildModule, modFromData, function, funcDecDef,
innerType)
import qualified Drasil.Shared.LanguageRenderer as R (commentedMod,
commentedItem, parameterList, body, addComments, multiStmt, sqrt, abs, log10,
log, exp, sin, cos, tan, asin, acos, atan, floor, ceil, break, continue,
elseIfLabel)
import qualified Drasil.GProc.RendererClassesProc as RC (module')
import qualified Drasil.Shared.LanguageRenderer.LanguagePolymorphic as G (
comment, param, docFunc, var, multiBody, block, multiBlock, stmt, loopStmt,
negateOp, plusOp, minusOp, multOp, divideOp, equalOp, greaterOp,
greaterEqualOp, lessOp, lessEqualOp, csc, sec, cot, valueOf, litDouble,
litInt, litString, valStmt, emptyStmt, assign, funcAppMixedArgs, call, print,
ifCond, tryCatch, listAccess)
import qualified Drasil.Shared.LanguageRenderer.CommonPseudoOO as CP (mainBody,
functionDoc, docInOutFunc', inOutCall, multiAssign, intToIndex', indexToInt',
listDecDef)
import qualified Drasil.Shared.LanguageRenderer.CLike as C (andOp, orOp, litTrue,
litFalse, while)
import qualified Drasil.Shared.LanguageRenderer.Common as CS (varDecDef,
extFuncAppMixedArgs, listSize, forEach')
import qualified Drasil.Shared.LanguageRenderer.Macros as M (ifExists,
increment1, decrement1)
import Drasil.Shared.AST (Terminator(..), FileType(Combined), fileD, md,
updateMod, MethodData, mthd, updateMthd, ParamData, paramVar, paramDoc, pd,
ProgData, TypeData, cType, vd, val, valPrec, valInt, valType, opDoc, opPrec,
varName, varType, varBind, varDoc, vard, progD, mthdDoc, modDoc)
import Drasil.Shared.CodeType (CodeType(..))
import Drasil.Shared.LanguageRenderer.Constructors (typeFromData, unOpPrec,
powerPrec, unExpr, unExpr', binExpr, mkStateVal, mkVal, mkStateVar, mkStmtNoEnd,
compEqualPrec, typeUnExpr, typeBinExpr)
import Drasil.Shared.LanguageRenderer (listSep', valueList, intValue)
import Drasil.Shared.LanguageRenderer.LanguagePolymorphic (OptionalSpace(..))
import Drasil.Shared.Helpers (toCode, toState, onCodeValue, onStateValue,
onCodeList, onStateList, on2CodeValues, on2StateValues, emptyIfEmpty)
import Drasil.Shared.State (MS, VS, FS, lensGStoFS, lensMStoVS, revFiles,
setFileType, getMainDoc)
import Control.Lens.Zoom (zoom)
import Control.Monad.State (modify)
import Drasil.FileHandling.Legacy (indent)
import Prelude hiding (break,print,sin,cos,tan,floor,(<>))
import Text.PrettyPrint.HughesPJ (Doc, empty, text, (<>), (<+>), vcat, hcat,
parens, brackets, braces, equals, punctuate, render)
newtype MatlabCode a = MLC {forall a. MatlabCode a -> a
unMLC :: a} deriving (forall a b. (a -> b) -> MatlabCode a -> MatlabCode b)
-> (forall a b. a -> MatlabCode b -> MatlabCode a)
-> Functor MatlabCode
forall a b. a -> MatlabCode b -> MatlabCode a
forall a b. (a -> b) -> MatlabCode a -> MatlabCode b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> MatlabCode a -> MatlabCode b
fmap :: forall a b. (a -> b) -> MatlabCode a -> MatlabCode b
$c<$ :: forall a b. a -> MatlabCode b -> MatlabCode a
<$ :: forall a b. a -> MatlabCode b -> MatlabCode a
Functor
instance Applicative MatlabCode where
pure :: forall a. a -> MatlabCode a
pure = a -> MatlabCode a
forall a. a -> MatlabCode a
MLC
(MLC a -> b
f) <*> :: forall a b. MatlabCode (a -> b) -> MatlabCode a -> MatlabCode b
<*> (MLC a
x) = b -> MatlabCode b
forall a. a -> MatlabCode a
MLC (a -> b
f a
x)
instance Monad MatlabCode where
MLC a
x >>= :: forall a b. MatlabCode a -> (a -> MatlabCode b) -> MatlabCode b
>>= a -> MatlabCode b
f = a -> MatlabCode b
f a
x
instance SharedProg MatlabCode Doc (Doc, Terminator) MethodData
instance SharedStatement MatlabCode (Doc, Terminator)
instance ProcProg MatlabCode Doc (Doc, Terminator) MethodData ProgData
instance ProgramSym MatlabCode Doc (Doc, Terminator) MethodData ProgData where
prog :: Label
-> Label -> [FS (MatlabCode File)] -> GSProgram MatlabCode ProgData
prog Label
n Label
st [FS (MatlabCode File)]
files = do
[MatlabCode File]
fs <- (FS (MatlabCode File)
-> StateT GOOLState Identity (MatlabCode File))
-> [FS (MatlabCode File)]
-> StateT GOOLState Identity [MatlabCode File]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (LensLike'
(Zoomed (StateT FileState Identity) (MatlabCode File))
GOOLState
FileState
-> FS (MatlabCode File)
-> StateT GOOLState Identity (MatlabCode File)
forall c.
LensLike'
(Zoomed (StateT FileState Identity) c) GOOLState FileState
-> StateT FileState Identity c -> StateT GOOLState Identity c
forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom LensLike'
(Zoomed (StateT FileState Identity) (MatlabCode File))
GOOLState
FileState
(FileState -> Focusing Identity (MatlabCode File) FileState)
-> GOOLState -> Focusing Identity (MatlabCode File) GOOLState
Lens' GOOLState FileState
lensGStoFS) [FS (MatlabCode File)]
files
(GOOLState -> GOOLState) -> StateT GOOLState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify GOOLState -> GOOLState
revFiles
MatlabCode ProgData -> GSProgram MatlabCode ProgData
forall a. a -> StateT GOOLState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (MatlabCode ProgData -> GSProgram MatlabCode ProgData)
-> MatlabCode ProgData -> GSProgram MatlabCode ProgData
forall a b. (a -> b) -> a -> b
$ ([File] -> ProgData) -> [MatlabCode File] -> MatlabCode ProgData
forall (m :: * -> *) a b. Monad m => ([a] -> b) -> [m a] -> m b
onCodeList (Label -> Label -> [File] -> ProgData
progD Label
n Label
st) [MatlabCode File]
fs
instance CommonRenderSym MatlabCode Doc (Doc, Terminator) MethodData
instance ProcRenderSym MatlabCode Doc (Doc, Terminator) MethodData
instance UnRepr MatlabCode inner where
unRepr :: MatlabCode inner -> inner
unRepr = MatlabCode inner -> inner
forall a. MatlabCode a -> a
unMLC
instance FileSym MatlabCode Doc (Doc, Terminator) MethodData where
fileDoc :: FS (MatlabCode Module) -> FS (MatlabCode File)
fileDoc FS (MatlabCode Module)
m = do
(FileState -> FileState) -> StateT FileState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (FileType -> FileState -> FileState
setFileType FileType
Combined)
Label -> FS (MatlabCode Module) -> FS (MatlabCode File)
forall (r :: * -> *).
RenderFile r =>
Label -> FS (r Module) -> FS (r File)
A.fileDoc Label
mlExt FS (MatlabCode Module)
m
docMod :: Label
-> Label
-> [Label]
-> Label
-> FS (MatlabCode File)
-> FS (MatlabCode File)
docMod = Label
-> Label
-> Label
-> [Label]
-> Label
-> FS (MatlabCode File)
-> FS (MatlabCode File)
forall (r :: * -> *).
RenderFile r =>
Label
-> Label -> Label -> [Label] -> Label -> FS (r File) -> FS (r File)
A.docMod Label
mlExt
instance RenderFile MatlabCode where
top :: MatlabCode Module -> MatlabCode Doc
top MatlabCode Module
_ = Doc -> MatlabCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
empty
bottom :: MatlabCode Doc
bottom = Doc -> MatlabCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
empty
commentedMod :: FS (MatlabCode File) -> FS (MatlabCode Doc) -> FS (MatlabCode File)
commentedMod = (MatlabCode File -> MatlabCode Doc -> MatlabCode File)
-> FS (MatlabCode File)
-> FS (MatlabCode Doc)
-> FS (MatlabCode File)
forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues ((File -> Doc -> File)
-> MatlabCode File -> MatlabCode Doc -> MatlabCode File
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues File -> Doc -> File
R.commentedMod)
fileFromData :: Label -> FS (MatlabCode Module) -> FS (MatlabCode File)
fileFromData = (Label -> MatlabCode Module -> MatlabCode File)
-> Label -> FS (MatlabCode Module) -> FS (MatlabCode File)
forall (r :: * -> *).
ModuleElim r =>
(Label -> r Module -> r File)
-> Label -> FS (r Module) -> FS (r File)
A.fileFromData ((Module -> File) -> MatlabCode Module -> MatlabCode File
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ((Module -> File) -> MatlabCode Module -> MatlabCode File)
-> (Label -> Module -> File)
-> Label
-> MatlabCode Module
-> MatlabCode File
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Label -> Module -> File
fileD)
instance ImportSym MatlabCode where
langImport :: Label -> MatlabCode Doc
langImport = Label -> MatlabCode Doc
forall a. HasCallStack => a
undefined
modImport :: Label -> MatlabCode Doc
modImport = Label -> MatlabCode Doc
forall a. HasCallStack => a
undefined
instance BodySym MatlabCode (Doc, Terminator) where
body :: [MS (MatlabCode Doc)] -> MS (MatlabCode Doc)
body = ([MatlabCode Doc] -> MatlabCode Doc)
-> [MS (MatlabCode Doc)] -> MS (MatlabCode Doc)
forall a b s. ([a] -> b) -> [State s a] -> State s b
onStateList (([Doc] -> Doc) -> [MatlabCode Doc] -> MatlabCode Doc
forall (m :: * -> *) a b. Monad m => ([a] -> b) -> [m a] -> m b
onCodeList [Doc] -> Doc
R.body)
addComments :: Label -> MS (MatlabCode Doc) -> MS (MatlabCode Doc)
addComments Label
s = (MatlabCode Doc -> MatlabCode Doc)
-> MS (MatlabCode Doc) -> MS (MatlabCode Doc)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue ((Doc -> Doc) -> MatlabCode Doc -> MatlabCode Doc
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue (Label -> Doc -> Doc -> Doc
R.addComments Label
s Doc
mlCmtStart))
instance RenderBody MatlabCode where
multiBody :: [MS (MatlabCode Doc)] -> MS (MatlabCode Doc)
multiBody = [MS (MatlabCode Doc)] -> MS (MatlabCode Doc)
forall (r :: * -> *).
(BodyElim r, Monad r) =>
[MS (r Doc)] -> MS (r Doc)
G.multiBody
instance BodyElim MatlabCode where
body :: MatlabCode Doc -> Doc
body = MatlabCode Doc -> Doc
forall a. MatlabCode a -> a
unMLC
instance BlockSym MatlabCode (Doc, Terminator) where
block :: [MS (MatlabCode (Doc, Terminator))] -> MS (MatlabCode Doc)
block = [MS (MatlabCode (Doc, Terminator))] -> MS (MatlabCode Doc)
forall (r :: * -> *) smt.
(Monad r, RenderStatement r smt, StatementElim r smt) =>
[MS (r smt)] -> MS (r Doc)
G.block
instance RenderBlock MatlabCode where
multiBlock :: [MS (MatlabCode Doc)] -> MS (MatlabCode Doc)
multiBlock = [MS (MatlabCode Doc)] -> MS (MatlabCode Doc)
forall (r :: * -> *).
(BlockElim r, Monad r) =>
[MS (r Doc)] -> MS (r Doc)
G.multiBlock
instance BlockElim MatlabCode where
block :: MatlabCode Doc -> Doc
block = MatlabCode Doc -> Doc
forall a. MatlabCode a -> a
unMLC
instance TypeSym MatlabCode where
bool :: VS (MatlabCode TypeData)
bool = CodeType -> Label -> VS (MatlabCode TypeData)
mlTy CodeType
Boolean Label
"logical"
int :: VS (MatlabCode TypeData)
int = CodeType -> Label -> VS (MatlabCode TypeData)
mlTy CodeType
Integer Label
"int"
float :: VS (MatlabCode TypeData)
float = CodeType -> Label -> VS (MatlabCode TypeData)
mlTy CodeType
Float Label
"double"
double :: VS (MatlabCode TypeData)
double = CodeType -> Label -> VS (MatlabCode TypeData)
mlTy CodeType
Double Label
"double"
char :: VS (MatlabCode TypeData)
char = CodeType -> Label -> VS (MatlabCode TypeData)
mlTy CodeType
Char Label
"char"
string :: VS (MatlabCode TypeData)
string = CodeType -> Label -> VS (MatlabCode TypeData)
mlTy CodeType
String Label
"string"
infile :: VS (MatlabCode TypeData)
infile = CodeType -> Label -> VS (MatlabCode TypeData)
mlTy CodeType
InFile Label
"file"
outfile :: VS (MatlabCode TypeData)
outfile = CodeType -> Label -> VS (MatlabCode TypeData)
mlTy CodeType
OutFile Label
"file"
referenceType :: VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
referenceType = VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall a. a -> a
id
listType :: VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
listType = VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
mlListType
setType :: VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
setType = VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall a. HasCallStack => a
undefined
arrayType :: VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
arrayType = VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall (r :: * -> *).
TypeSym r =>
VS (r TypeData) -> VS (r TypeData)
listType
innerType :: VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
innerType = VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall a. HasCallStack => a
undefined
funcType :: [VS (MatlabCode TypeData)]
-> VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
funcType = [VS (MatlabCode TypeData)]
-> VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall a. HasCallStack => a
undefined
void :: VS (MatlabCode TypeData)
void = CodeType -> Label -> VS (MatlabCode TypeData)
mlTy CodeType
Void Label
"void"
instance TypeElim MatlabCode where
getCodeType :: MatlabCode TypeData -> CodeType
getCodeType = TypeData -> CodeType
cType (TypeData -> CodeType)
-> (MatlabCode TypeData -> TypeData)
-> MatlabCode TypeData
-> CodeType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode TypeData -> TypeData
forall a. MatlabCode a -> a
unMLC
instance RenderType MatlabCode where
multiType :: [VS (MatlabCode TypeData)] -> VS (MatlabCode TypeData)
multiType = [VS (MatlabCode TypeData)] -> VS (MatlabCode TypeData)
forall a. HasCallStack => a
undefined
instance UnaryOpSym MatlabCode where
notOp :: VSUnOp MatlabCode
notOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
"~"
negateOp :: VSUnOp MatlabCode
negateOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
G.negateOp
sqrtOp :: VSUnOp MatlabCode
sqrtOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.sqrt
absOp :: VSUnOp MatlabCode
absOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.abs
logOp :: VSUnOp MatlabCode
logOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.log10
lnOp :: VSUnOp MatlabCode
lnOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.log
expOp :: VSUnOp MatlabCode
expOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.exp
sinOp :: VSUnOp MatlabCode
sinOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.sin
cosOp :: VSUnOp MatlabCode
cosOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.cos
tanOp :: VSUnOp MatlabCode
tanOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.tan
asinOp :: VSUnOp MatlabCode
asinOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.asin
acosOp :: VSUnOp MatlabCode
acosOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.acos
atanOp :: VSUnOp MatlabCode
atanOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.atan
floorOp :: VSUnOp MatlabCode
floorOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.floor
ceilOp :: VSUnOp MatlabCode
ceilOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
unOpPrec Label
R.ceil
instance BinaryOpSym MatlabCode where
equalOp :: VSUnOp MatlabCode
equalOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
G.equalOp
notEqualOp :: VSUnOp MatlabCode
notEqualOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
compEqualPrec Label
"~="
greaterOp :: VSUnOp MatlabCode
greaterOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
G.greaterOp
greaterEqualOp :: VSUnOp MatlabCode
greaterEqualOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
G.greaterEqualOp
lessOp :: VSUnOp MatlabCode
lessOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
G.lessOp
lessEqualOp :: VSUnOp MatlabCode
lessEqualOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
G.lessEqualOp
plusOp :: VSUnOp MatlabCode
plusOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
G.plusOp
minusOp :: VSUnOp MatlabCode
minusOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
G.minusOp
multOp :: VSUnOp MatlabCode
multOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
G.multOp
divideOp :: VSUnOp MatlabCode
divideOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
G.divideOp
powerOp :: VSUnOp MatlabCode
powerOp = Label -> VSUnOp MatlabCode
forall (r :: * -> *). Monad r => Label -> VSOp r
powerPrec Label
"^"
moduloOp :: VSUnOp MatlabCode
moduloOp = VSUnOp MatlabCode
forall a. HasCallStack => a
undefined
andOp :: VSUnOp MatlabCode
andOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
C.andOp
orOp :: VSUnOp MatlabCode
orOp = VSUnOp MatlabCode
forall (r :: * -> *). Monad r => VSOp r
C.orOp
instance OpElim MatlabCode where
uOp :: MatlabCode OpData -> Doc
uOp = OpData -> Doc
opDoc (OpData -> Doc)
-> (MatlabCode OpData -> OpData) -> MatlabCode OpData -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode OpData -> OpData
forall a. MatlabCode a -> a
unMLC
bOp :: MatlabCode OpData -> Doc
bOp = OpData -> Doc
opDoc (OpData -> Doc)
-> (MatlabCode OpData -> OpData) -> MatlabCode OpData -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode OpData -> OpData
forall a. MatlabCode a -> a
unMLC
uOpPrec :: MatlabCode OpData -> Int
uOpPrec = OpData -> Int
opPrec (OpData -> Int)
-> (MatlabCode OpData -> OpData) -> MatlabCode OpData -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode OpData -> OpData
forall a. MatlabCode a -> a
unMLC
bOpPrec :: MatlabCode OpData -> Int
bOpPrec = OpData -> Int
opPrec (OpData -> Int)
-> (MatlabCode OpData -> OpData) -> MatlabCode OpData -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode OpData -> OpData
forall a. MatlabCode a -> a
unMLC
instance ScopeSym MatlabCode where
global :: MatlabCode ScopeData
global = MatlabCode ScopeData
forall a. HasCallStack => a
undefined
mainFn :: MatlabCode ScopeData
mainFn = MatlabCode ScopeData
forall a. HasCallStack => a
undefined
local :: MatlabCode ScopeData
local = MatlabCode ScopeData
forall a. HasCallStack => a
undefined
instance ScopeElim MatlabCode where
scopeData :: MatlabCode ScopeData -> ScopeData
scopeData = MatlabCode ScopeData -> ScopeData
forall a. MatlabCode a -> a
unMLC
instance VariableSym MatlabCode where
var :: Label -> VS (MatlabCode TypeData) -> SVariable MatlabCode
var = Label -> VS (MatlabCode TypeData) -> SVariable MatlabCode
forall (r :: * -> *).
RenderVariable r =>
Label -> VS (r TypeData) -> SVariable r
G.var
constant :: Label -> VS (MatlabCode TypeData) -> SVariable MatlabCode
constant = Label -> VS (MatlabCode TypeData) -> SVariable MatlabCode
forall (r :: * -> *).
VariableSym r =>
Label -> VS (r TypeData) -> SVariable r
var
extVar :: Label -> Label -> VS (MatlabCode TypeData) -> SVariable MatlabCode
extVar = Label -> Label -> VS (MatlabCode TypeData) -> SVariable MatlabCode
forall a. HasCallStack => a
undefined
instance VariableElim MatlabCode where
variableName :: MatlabCode Variable -> Label
variableName = Variable -> Label
varName (Variable -> Label)
-> (MatlabCode Variable -> Variable)
-> MatlabCode Variable
-> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode Variable -> Variable
forall a. MatlabCode a -> a
unMLC
variableType :: MatlabCode Variable -> MatlabCode TypeData
variableType = (Variable -> TypeData)
-> MatlabCode Variable -> MatlabCode TypeData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue Variable -> TypeData
varType
instance InternalVarElim MatlabCode where
variableBind :: MatlabCode Variable -> AttachmentTag
variableBind = Variable -> AttachmentTag
varBind (Variable -> AttachmentTag)
-> (MatlabCode Variable -> Variable)
-> MatlabCode Variable
-> AttachmentTag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode Variable -> Variable
forall a. MatlabCode a -> a
unMLC
variable :: MatlabCode Variable -> Doc
variable = Variable -> Doc
varDoc (Variable -> Doc)
-> (MatlabCode Variable -> Variable) -> MatlabCode Variable -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode Variable -> Variable
forall a. MatlabCode a -> a
unMLC
instance RenderVariable MatlabCode where
varFromData :: AttachmentTag
-> Label -> VS (MatlabCode TypeData) -> Doc -> SVariable MatlabCode
varFromData AttachmentTag
b Label
n VS (MatlabCode TypeData)
t' Doc
d = do
MatlabCode TypeData
t <- VS (MatlabCode TypeData)
t'
MatlabCode Variable -> SVariable MatlabCode
forall a s. a -> State s a
toState (MatlabCode Variable -> SVariable MatlabCode)
-> MatlabCode Variable -> SVariable MatlabCode
forall a b. (a -> b) -> a -> b
$ (TypeData -> Doc -> Variable)
-> MatlabCode TypeData -> MatlabCode Doc -> MatlabCode Variable
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues (AttachmentTag -> Label -> TypeData -> Doc -> Variable
vard AttachmentTag
b Label
n) MatlabCode TypeData
t (Doc -> MatlabCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
d)
instance ValueSym MatlabCode where
valueType :: MatlabCode Value -> MatlabCode TypeData
valueType MatlabCode Value
v = Value -> TypeData
valType (Value -> TypeData) -> MatlabCode Value -> MatlabCode TypeData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
<$> MatlabCode Value
v
instance Argument MatlabCode where
pointerArg :: SValue MatlabCode -> SValue MatlabCode
pointerArg = SValue MatlabCode -> SValue MatlabCode
forall a. HasCallStack => a
undefined
instance Literal MatlabCode where
litTrue :: SValue MatlabCode
litTrue = SValue MatlabCode
forall (r :: * -> *). (RenderValue r, TypeSym r) => SValue r
C.litTrue
litFalse :: SValue MatlabCode
litFalse = SValue MatlabCode
forall (r :: * -> *). (RenderValue r, TypeSym r) => SValue r
C.litFalse
litChar :: Char -> SValue MatlabCode
litChar = Char -> SValue MatlabCode
forall a. HasCallStack => a
undefined
litDouble :: Double -> SValue MatlabCode
litDouble = Double -> SValue MatlabCode
forall (r :: * -> *).
(RenderValue r, TypeSym r) =>
Double -> SValue r
G.litDouble
litFloat :: Float -> SValue MatlabCode
litFloat = Float -> SValue MatlabCode
forall a. HasCallStack => a
undefined
litInt :: Integer -> SValue MatlabCode
litInt = Integer -> SValue MatlabCode
forall (r :: * -> *).
(RenderValue r, TypeSym r) =>
Integer -> SValue r
G.litInt
litString :: Label -> SValue MatlabCode
litString = Label -> SValue MatlabCode
forall (r :: * -> *).
(RenderValue r, TypeSym r) =>
Label -> SValue r
G.litString
litArray :: VS (MatlabCode TypeData)
-> [SValue MatlabCode] -> SValue MatlabCode
litArray = VS (MatlabCode TypeData)
-> [SValue MatlabCode] -> SValue MatlabCode
forall (r :: * -> *).
Literal r =>
VS (r TypeData) -> [SValue r] -> SValue r
litList
litList :: VS (MatlabCode TypeData)
-> [SValue MatlabCode] -> SValue MatlabCode
litList = VS (MatlabCode TypeData)
-> [SValue MatlabCode] -> SValue MatlabCode
mlLitList
litSet :: VS (MatlabCode TypeData)
-> [SValue MatlabCode] -> SValue MatlabCode
litSet = VS (MatlabCode TypeData)
-> [SValue MatlabCode] -> SValue MatlabCode
forall a. HasCallStack => a
undefined
instance MathConstant MatlabCode where
pi :: SValue MatlabCode
pi = VS (MatlabCode TypeData) -> Doc -> SValue MatlabCode
forall (r :: * -> *).
RenderValue r =>
VS (r TypeData) -> Doc -> SValue r
mkStateVal VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
double (Label -> Doc
text Label
"pi")
instance VariableValue MatlabCode where
valueOf :: SVariable MatlabCode -> SValue MatlabCode
valueOf = SVariable MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(InternalVarElim r, RenderValue r, VariableElim r) =>
SVariable r -> SValue r
G.valueOf
instance CommandLineArgs MatlabCode where
arg :: Integer -> SValue MatlabCode
arg Integer
n = SValue MatlabCode -> SValue MatlabCode
mlArg (Integer -> SValue MatlabCode
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt (Integer
n Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
1))
argsList :: SValue MatlabCode
argsList = VS (MatlabCode TypeData) -> Doc -> SValue MatlabCode
forall (r :: * -> *).
RenderValue r =>
VS (r TypeData) -> Doc -> SValue r
mkStateVal (VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall (r :: * -> *).
TypeSym r =>
VS (r TypeData) -> VS (r TypeData)
arrayType VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
string) (Label -> Doc
text Label
"varargin")
argExists :: Integer -> SValue MatlabCode
argExists = Integer -> SValue MatlabCode
forall a. HasCallStack => a
undefined
instance NumericExpression MatlabCode where
#~ :: SValue MatlabCode -> SValue MatlabCode
(#~) = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr' VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
negateOp
#/^ :: SValue MatlabCode -> SValue MatlabCode
(#/^) = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
sqrtOp
#| :: SValue MatlabCode -> SValue MatlabCode
(#|) = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
absOp
#+ :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(#+) = VSUnOp MatlabCode
-> SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, TypeElim r, ValueElim r, ValueSym r) =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
plusOp
#- :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(#-) = VSUnOp MatlabCode
-> SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, TypeElim r, ValueElim r, ValueSym r) =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
minusOp
#* :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(#*) = VSUnOp MatlabCode
-> SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, TypeElim r, ValueElim r, ValueSym r) =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
multOp
#/ :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(#/) = VSUnOp MatlabCode
-> SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, TypeElim r, ValueElim r, ValueSym r) =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
divideOp
#% :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(#%) = SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall a. HasCallStack => a
undefined
#^ :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(#^) = VSUnOp MatlabCode
-> SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, TypeElim r, ValueElim r, ValueSym r) =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
powerOp
log :: SValue MatlabCode -> SValue MatlabCode
log = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
logOp
ln :: SValue MatlabCode -> SValue MatlabCode
ln = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
lnOp
exp :: SValue MatlabCode -> SValue MatlabCode
exp = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
expOp
sin :: SValue MatlabCode -> SValue MatlabCode
sin = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
sinOp
cos :: SValue MatlabCode -> SValue MatlabCode
cos = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
cosOp
tan :: SValue MatlabCode -> SValue MatlabCode
tan = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
tanOp
csc :: SValue MatlabCode -> SValue MatlabCode
csc = SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(Literal r, NumericExpression r, TypeElim r) =>
SValue r -> SValue r
G.csc
sec :: SValue MatlabCode -> SValue MatlabCode
sec = SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(Literal r, NumericExpression r, TypeElim r) =>
SValue r -> SValue r
G.sec
cot :: SValue MatlabCode -> SValue MatlabCode
cot = SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(Literal r, NumericExpression r, TypeElim r) =>
SValue r -> SValue r
G.cot
arcsin :: SValue MatlabCode -> SValue MatlabCode
arcsin = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
asinOp
arccos :: SValue MatlabCode -> SValue MatlabCode
arccos = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
acosOp
arctan :: SValue MatlabCode -> SValue MatlabCode
arctan = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
atanOp
floor :: SValue MatlabCode -> SValue MatlabCode
floor = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
floorOp
ceil :: SValue MatlabCode -> SValue MatlabCode
ceil = VSUnOp MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r, ValueSym r) =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
ceilOp
instance BooleanExpression MatlabCode where
?! :: SValue MatlabCode -> SValue MatlabCode
(?!) = VSUnOp MatlabCode
-> VS (MatlabCode TypeData)
-> SValue MatlabCode
-> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r) =>
VSUnOp r -> VS (r TypeData) -> SValue r -> SValue r
typeUnExpr VSUnOp MatlabCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
notOp VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool
?&& :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(?&&) = VSUnOp MatlabCode
-> VS (MatlabCode TypeData)
-> SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r) =>
VSBinOp r -> VS (r TypeData) -> SValue r -> SValue r -> SValue r
typeBinExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
andOp VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool
?|| :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(?||) = VSUnOp MatlabCode
-> VS (MatlabCode TypeData)
-> SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r) =>
VSBinOp r -> VS (r TypeData) -> SValue r -> SValue r -> SValue r
typeBinExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
orOp VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool
instance Comparison MatlabCode where
?< :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(?<) = VSUnOp MatlabCode
-> VS (MatlabCode TypeData)
-> SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r) =>
VSBinOp r -> VS (r TypeData) -> SValue r -> SValue r -> SValue r
typeBinExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
lessOp VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool
?<= :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(?<=) = VSUnOp MatlabCode
-> VS (MatlabCode TypeData)
-> SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r) =>
VSBinOp r -> VS (r TypeData) -> SValue r -> SValue r -> SValue r
typeBinExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
lessEqualOp VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool
?> :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(?>) = VSUnOp MatlabCode
-> VS (MatlabCode TypeData)
-> SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r) =>
VSBinOp r -> VS (r TypeData) -> SValue r -> SValue r -> SValue r
typeBinExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
greaterOp VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool
?>= :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(?>=) = VSUnOp MatlabCode
-> VS (MatlabCode TypeData)
-> SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r) =>
VSBinOp r -> VS (r TypeData) -> SValue r -> SValue r -> SValue r
typeBinExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
greaterEqualOp VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool
?== :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(?==) = VSUnOp MatlabCode
-> VS (MatlabCode TypeData)
-> SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r) =>
VSBinOp r -> VS (r TypeData) -> SValue r -> SValue r -> SValue r
typeBinExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
equalOp VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool
?!= :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
(?!=) = VSUnOp MatlabCode
-> VS (MatlabCode TypeData)
-> SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, ValueElim r) =>
VSBinOp r -> VS (r TypeData) -> SValue r -> SValue r -> SValue r
typeBinExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
notEqualOp VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool
instance ValueExpression MatlabCode where
inlineIf :: SValue MatlabCode
-> SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
inlineIf = SValue MatlabCode
-> SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall a. HasCallStack => a
undefined
funcAppMixedArgs :: MixedCall MatlabCode
funcAppMixedArgs = MixedCall MatlabCode
forall (r :: * -> *). RenderValue r => MixedCall r
G.funcAppMixedArgs
extFuncAppMixedArgs :: Label -> MixedCall MatlabCode
extFuncAppMixedArgs = Label -> MixedCall MatlabCode
forall (r :: * -> *). RenderValue r => Label -> MixedCall r
CS.extFuncAppMixedArgs
libFuncAppMixedArgs :: Label -> MixedCall MatlabCode
libFuncAppMixedArgs = Label -> MixedCall MatlabCode
forall (r :: * -> *). RenderValue r => Label -> MixedCall r
CS.extFuncAppMixedArgs
lambda :: [VSBinder MatlabCode] -> SValue MatlabCode -> SValue MatlabCode
lambda = [VSBinder MatlabCode] -> SValue MatlabCode -> SValue MatlabCode
forall a. HasCallStack => a
undefined
notNull :: SValue MatlabCode -> SValue MatlabCode
notNull = SValue MatlabCode -> SValue MatlabCode
forall a. HasCallStack => a
undefined
instance RenderValue MatlabCode where
inputFunc :: SValue MatlabCode
inputFunc = SValue MatlabCode
forall a. HasCallStack => a
undefined
printFunc :: SValue MatlabCode
printFunc = SValue MatlabCode
mlPrintFunc
printLnFunc :: SValue MatlabCode
printLnFunc = SValue MatlabCode
mlPrintFunc
printFileFunc :: SValue MatlabCode -> SValue MatlabCode
printFileFunc SValue MatlabCode
_ = SValue MatlabCode
mlPrintFunc
printFileLnFunc :: SValue MatlabCode -> SValue MatlabCode
printFileLnFunc SValue MatlabCode
_ = SValue MatlabCode
mlPrintFunc
cast :: VS (MatlabCode TypeData) -> SValue MatlabCode -> SValue MatlabCode
cast = VS (MatlabCode TypeData) -> SValue MatlabCode -> SValue MatlabCode
forall a. HasCallStack => a
undefined
call :: Maybe Label -> Maybe Doc -> MixedCall MatlabCode
call = Doc -> Maybe Label -> Maybe Doc -> MixedCall MatlabCode
forall (r :: * -> *).
(InternalVarElim r, RenderValue r, ValueElim r) =>
Doc -> Maybe Label -> Maybe Doc -> MixedCall r
G.call Doc
equals
valFromData :: Maybe Int
-> Maybe Integer
-> VS (MatlabCode TypeData)
-> Doc
-> SValue MatlabCode
valFromData Maybe Int
p Maybe Integer
i VS (MatlabCode TypeData)
t' Doc
d = do
MatlabCode TypeData
t <- VS (MatlabCode TypeData)
t'
MatlabCode Value -> SValue MatlabCode
forall a s. a -> State s a
toState (MatlabCode Value -> SValue MatlabCode)
-> MatlabCode Value -> SValue MatlabCode
forall a b. (a -> b) -> a -> b
$ (TypeData -> Doc -> Value)
-> MatlabCode TypeData -> MatlabCode Doc -> MatlabCode Value
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues (Maybe Int -> Maybe Integer -> TypeData -> Doc -> Value
vd Maybe Int
p Maybe Integer
i) MatlabCode TypeData
t (Doc -> MatlabCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
d)
instance ValueElim MatlabCode where
valuePrec :: MatlabCode Value -> Maybe Int
valuePrec = Value -> Maybe Int
valPrec (Value -> Maybe Int)
-> (MatlabCode Value -> Value) -> MatlabCode Value -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode Value -> Value
forall a. MatlabCode a -> a
unMLC
valueInt :: MatlabCode Value -> Maybe Integer
valueInt = Value -> Maybe Integer
valInt (Value -> Maybe Integer)
-> (MatlabCode Value -> Value) -> MatlabCode Value -> Maybe Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode Value -> Value
forall a. MatlabCode a -> a
unMLC
value :: MatlabCode Value -> Doc
value = Value -> Doc
val (Value -> Doc)
-> (MatlabCode Value -> Value) -> MatlabCode Value -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode Value -> Value
forall a. MatlabCode a -> a
unMLC
instance IndexTranslator MatlabCode where
intToIndex :: SValue MatlabCode -> SValue MatlabCode
intToIndex = SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(Literal r, NumericExpression r, RenderValue r, ValueElim r) =>
SValue r -> SValue r
CP.intToIndex'
indexToInt :: SValue MatlabCode -> SValue MatlabCode
indexToInt = SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(Literal r, NumericExpression r, RenderValue r, ValueElim r) =>
SValue r -> SValue r
CP.indexToInt'
instance Reference MatlabCode where
makeRef :: SValue MatlabCode -> SValue MatlabCode
makeRef = SValue MatlabCode -> SValue MatlabCode
forall a. a -> a
id
maybeDeref :: SValue MatlabCode -> SValue MatlabCode
maybeDeref = SValue MatlabCode -> SValue MatlabCode
forall a. a -> a
id
instance Array MatlabCode where
arrayElem :: SValue MatlabCode -> SValue MatlabCode -> SVariable MatlabCode
arrayElem = SValue MatlabCode -> SValue MatlabCode -> SVariable MatlabCode
mlArrayElem
arrayLength :: SValue MatlabCode -> SValue MatlabCode
arrayLength = SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *) smt. List r smt => SValue r -> SValue r
listSize
arrayCopy :: SValue MatlabCode -> SValue MatlabCode
arrayCopy SValue MatlabCode
arr = let arrTp :: VS (MatlabCode TypeData)
arrTp = (MatlabCode Value -> MatlabCode TypeData)
-> SValue MatlabCode -> VS (MatlabCode TypeData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue MatlabCode Value -> MatlabCode TypeData
forall (r :: * -> *). ValueSym r => r Value -> r TypeData
valueType SValue MatlabCode
arr
in PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"copy" VS (MatlabCode TypeData)
arrTp [SValue MatlabCode
arr]
instance List MatlabCode (Doc, Terminator) where
listSize :: SValue MatlabCode -> SValue MatlabCode
listSize = Label -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
ValueExpression r =>
Label -> SValue r -> SValue r
CS.listSize Label
"length"
listAdd :: SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
listAdd = SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall a. HasCallStack => a
undefined
listAppend :: SValue MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
listAppend SValue MatlabCode
lst = SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
List r smt =>
SValue r -> SValue r -> SValue r -> MS (r smt)
listSet SValue MatlabCode
lst (SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *) smt. List r smt => SValue r -> SValue r
listSize SValue MatlabCode
lst)
listAccess :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
listAccess = SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(IndexTranslator r, InternalListFunc r, FunctionElim r,
RenderFunction r, RenderValue r, TypeElim r, ValueElim r) =>
SValue r -> SValue r -> SValue r
G.listAccess
listSet :: SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
listSet = SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
mlListSet
indexOf :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
indexOf SValue MatlabCode
lst SValue MatlabCode
v = PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"find" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
int [SValue MatlabCode
lst SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
Comparison r =>
SValue r -> SValue r -> SValue r
?== SValue MatlabCode
v, Integer -> SValue MatlabCode
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
1] SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
NumericExpression r =>
SValue r -> SValue r -> SValue r
#- Integer -> SValue MatlabCode
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
1
instance Set MatlabCode where
contains :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
contains SValue MatlabCode
s SValue MatlabCode
e = PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"ismember" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool [SValue MatlabCode
e, SValue MatlabCode
s]
setAdd :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
setAdd = SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall a. HasCallStack => a
undefined
setRemove :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
setRemove = SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall a. HasCallStack => a
undefined
setUnion :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
setUnion = SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall a. HasCallStack => a
undefined
instance NativeVector MatlabCode where
vecScale :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
vecScale = VSUnOp MatlabCode
-> SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, TypeElim r, ValueElim r, ValueSym r) =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
multOp
vecAdd :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
vecAdd = VSUnOp MatlabCode
-> SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(OpElim r, RenderValue r, TypeElim r, ValueElim r, ValueSym r) =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSUnOp MatlabCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
plusOp
vecIndex :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
vecIndex = SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
mlVecIndex
vecDot :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
vecDot SValue MatlabCode
a SValue MatlabCode
b = PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"dot" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
double [SValue MatlabCode
a, SValue MatlabCode
b]
vecMag :: SValue MatlabCode -> SValue MatlabCode
vecMag SValue MatlabCode
a = PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"norm" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
double [SValue MatlabCode
a]
vecUnit :: SValue MatlabCode -> SValue MatlabCode
vecUnit SValue MatlabCode
a = SValue MatlabCode
a SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
NumericExpression r =>
SValue r -> SValue r -> SValue r
#/ SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *). NativeVector r => SValue r -> SValue r
vecMag SValue MatlabCode
a
instance InternalList MatlabCode where
listSlice' :: Maybe (SValue MatlabCode)
-> Maybe (SValue MatlabCode)
-> Maybe (SValue MatlabCode)
-> SVariable MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode Doc)
listSlice' = Maybe (SValue MatlabCode)
-> Maybe (SValue MatlabCode)
-> Maybe (SValue MatlabCode)
-> SVariable MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode Doc)
forall a. HasCallStack => a
undefined
instance InternalListFunc MatlabCode where
listAccessFunc :: VS (MatlabCode TypeData)
-> SValue MatlabCode -> VS (MatlabCode FuncData)
listAccessFunc VS (MatlabCode TypeData)
t SValue MatlabCode
v = SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
(TypeElim r, ValueSym r) =>
SValue r -> SValue r
intValue SValue MatlabCode
v SValue MatlabCode
-> (MatlabCode Value -> VS (MatlabCode FuncData))
-> VS (MatlabCode FuncData)
forall a b.
StateT ValueState Identity a
-> (a -> StateT ValueState Identity b)
-> StateT ValueState Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((Doc -> VS (MatlabCode TypeData) -> VS (MatlabCode FuncData)
forall (r :: * -> *).
RenderFunction r =>
Doc -> VS (r TypeData) -> VS (r FuncData)
`funcFromData` VS (MatlabCode TypeData)
t) (Doc -> VS (MatlabCode FuncData))
-> (MatlabCode Value -> Doc)
-> MatlabCode Value
-> VS (MatlabCode FuncData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode Value -> Doc
forall (r :: * -> *) vis smt md.
CommonRenderSym r vis smt md =>
r Value -> Doc
mlListAccessFunc)
mlListAccessFunc :: (CommonRenderSym r vis smt md) => r Value -> Doc
mlListAccessFunc :: forall (r :: * -> *) vis smt md.
CommonRenderSym r vis smt md =>
r Value -> Doc
mlListAccessFunc r Value
v = Doc -> Doc
parens (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ r Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value r Value
v
instance BinderSym MatlabCode where
binder :: Label -> VS (MatlabCode TypeData) -> VSBinder MatlabCode
binder = Label -> VS (MatlabCode TypeData) -> VSBinder MatlabCode
forall a. HasCallStack => a
undefined
instance BinderElim MatlabCode where
binderName :: MatlabCode BinderD -> Label
binderName = MatlabCode BinderD -> Label
forall a. HasCallStack => a
undefined
binderType :: MatlabCode BinderD -> MatlabCode TypeData
binderType = MatlabCode BinderD -> MatlabCode TypeData
forall a. HasCallStack => a
undefined
instance InternalBinderElim MatlabCode where
binderElim :: MatlabCode BinderD -> Doc
binderElim = MatlabCode BinderD -> Doc
forall a. HasCallStack => a
undefined
instance RenderFunction MatlabCode where
funcFromData :: Doc -> VS (MatlabCode TypeData) -> VS (MatlabCode FuncData)
funcFromData = Doc -> VS (MatlabCode TypeData) -> VS (MatlabCode FuncData)
forall a. HasCallStack => a
undefined
instance FunctionElim MatlabCode where
functionType :: MatlabCode FuncData -> MatlabCode TypeData
functionType = MatlabCode FuncData -> MatlabCode TypeData
forall a. HasCallStack => a
undefined
function :: MatlabCode FuncData -> Doc
function = MatlabCode FuncData -> Doc
forall a. HasCallStack => a
undefined
instance InternalAssignStmt MatlabCode (Doc, Terminator) where
multiAssign :: [SVariable MatlabCode]
-> [SValue MatlabCode] -> MS (MatlabCode (Doc, Terminator))
multiAssign = (Doc -> Doc)
-> [SVariable MatlabCode]
-> [SValue MatlabCode]
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(AssignStatement r smt, InternalVarElim r, RenderValue r,
RenderVariable r, ValueElim r) =>
(Doc -> Doc) -> [SVariable r] -> [SValue r] -> MS (r smt)
CP.multiAssign Doc -> Doc
brackets
instance InternalIOStmt MatlabCode (Doc, Terminator) where
printSt :: Bool
-> Maybe (SValue MatlabCode)
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
printSt = Bool
-> Maybe (SValue MatlabCode)
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
mlPrint
instance InternalControlStmt MatlabCode (Doc, Terminator) where
multiReturn :: [SValue MatlabCode] -> MS (MatlabCode (Doc, Terminator))
multiReturn = [SValue MatlabCode] -> MS (MatlabCode (Doc, Terminator))
forall a. HasCallStack => a
undefined
instance RenderStatement MatlabCode (Doc, Terminator) where
stmt :: MS (MatlabCode (Doc, Terminator))
-> MS (MatlabCode (Doc, Terminator))
stmt = MS (MatlabCode (Doc, Terminator))
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(RenderStatement r smt, StatementElim r smt) =>
MS (r smt) -> MS (r smt)
G.stmt
loopStmt :: MS (MatlabCode (Doc, Terminator))
-> MS (MatlabCode (Doc, Terminator))
loopStmt = MS (MatlabCode (Doc, Terminator))
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(RenderStatement r smt, StatementElim r smt) =>
MS (r smt) -> MS (r smt)
G.loopStmt
stmtFromData :: Doc -> Terminator -> MS (MatlabCode (Doc, Terminator))
stmtFromData Doc
d Terminator
t = MatlabCode (Doc, Terminator) -> MS (MatlabCode (Doc, Terminator))
forall a s. a -> State s a
toState (MatlabCode (Doc, Terminator) -> MS (MatlabCode (Doc, Terminator)))
-> MatlabCode (Doc, Terminator)
-> MS (MatlabCode (Doc, Terminator))
forall a b. (a -> b) -> a -> b
$ (Doc, Terminator) -> MatlabCode (Doc, Terminator)
forall (r :: * -> *) a. Monad r => a -> r a
toCode (Doc
d, Terminator
t)
instance StatementElim MatlabCode (Doc, Terminator) where
statement :: MatlabCode (Doc, Terminator) -> Doc
statement = (Doc, Terminator) -> Doc
forall a b. (a, b) -> a
fst ((Doc, Terminator) -> Doc)
-> (MatlabCode (Doc, Terminator) -> (Doc, Terminator))
-> MatlabCode (Doc, Terminator)
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode (Doc, Terminator) -> (Doc, Terminator)
forall a. MatlabCode a -> a
unMLC
statementTerm :: MatlabCode (Doc, Terminator) -> Terminator
statementTerm = (Doc, Terminator) -> Terminator
forall a b. (a, b) -> b
snd ((Doc, Terminator) -> Terminator)
-> (MatlabCode (Doc, Terminator) -> (Doc, Terminator))
-> MatlabCode (Doc, Terminator)
-> Terminator
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode (Doc, Terminator) -> (Doc, Terminator)
forall a. MatlabCode a -> a
unMLC
instance StatementSym MatlabCode (Doc, Terminator) where
valStmt :: SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
valStmt = Terminator
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(RenderStatement r smt, ValueElim r) =>
Terminator -> SValue r -> MS (r smt)
G.valStmt Terminator
Semi
emptyStmt :: MS (MatlabCode (Doc, Terminator))
emptyStmt = MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt. RenderStatement r smt => MS (r smt)
G.emptyStmt
multi :: [MS (MatlabCode (Doc, Terminator))]
-> MS (MatlabCode (Doc, Terminator))
multi = ([MatlabCode (Doc, Terminator)] -> MatlabCode (Doc, Terminator))
-> [MS (MatlabCode (Doc, Terminator))]
-> MS (MatlabCode (Doc, Terminator))
forall a b s. ([a] -> b) -> [State s a] -> State s b
onStateList (([(Doc, Terminator)] -> (Doc, Terminator))
-> [MatlabCode (Doc, Terminator)] -> MatlabCode (Doc, Terminator)
forall (m :: * -> *) a b. Monad m => ([a] -> b) -> [m a] -> m b
onCodeList [(Doc, Terminator)] -> (Doc, Terminator)
R.multiStmt)
instance AssignStatement MatlabCode (Doc, Terminator) where
assign :: SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
assign = Terminator
-> SVariable MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(InternalVarElim r, RenderStatement r smt, ValueElim r) =>
Terminator -> SVariable r -> SValue r -> MS (r smt)
G.assign Terminator
Semi
&-= :: SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
(&-=) SVariable MatlabCode
vr SValue MatlabCode
v = SVariable MatlabCode
vr SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
AssignStatement r smt =>
SVariable r -> SValue r -> MS (r smt)
&= (SVariable MatlabCode -> SValue MatlabCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable MatlabCode
vr SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
NumericExpression r =>
SValue r -> SValue r -> SValue r
#- SValue MatlabCode
v)
&+= :: SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
(&+=) SVariable MatlabCode
vr SValue MatlabCode
v = SVariable MatlabCode
vr SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
AssignStatement r smt =>
SVariable r -> SValue r -> MS (r smt)
&= (SVariable MatlabCode -> SValue MatlabCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable MatlabCode
vr SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *).
NumericExpression r =>
SValue r -> SValue r -> SValue r
#+ SValue MatlabCode
v)
&++ :: SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
(&++) = SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(AssignStatement r smt, Literal r) =>
SVariable r -> MS (r smt)
M.increment1
&-- :: SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
(&--) = SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(AssignStatement r smt, Literal r) =>
SVariable r -> MS (r smt)
M.decrement1
instance DeclStatement MatlabCode (Doc, Terminator) where
varDec :: SVariable MatlabCode
-> MatlabCode ScopeData -> MS (MatlabCode (Doc, Terminator))
varDec SVariable MatlabCode
v MatlabCode ScopeData
scp = SVariable MatlabCode
-> MatlabCode ScopeData
-> Maybe (SValue MatlabCode)
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(AssignStatement r smt, ScopeElim r, VariableElim r) =>
SVariable r -> r ScopeData -> Maybe (SValue r) -> MS (r smt)
CS.varDecDef SVariable MatlabCode
v MatlabCode ScopeData
scp Maybe (SValue MatlabCode)
forall a. Maybe a
Nothing
varDecDef :: SVariable MatlabCode
-> MatlabCode ScopeData
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
varDecDef SVariable MatlabCode
v MatlabCode ScopeData
scp SValue MatlabCode
e = SVariable MatlabCode
-> MatlabCode ScopeData
-> Maybe (SValue MatlabCode)
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(AssignStatement r smt, ScopeElim r, VariableElim r) =>
SVariable r -> r ScopeData -> Maybe (SValue r) -> MS (r smt)
CS.varDecDef SVariable MatlabCode
v MatlabCode ScopeData
scp (SValue MatlabCode -> Maybe (SValue MatlabCode)
forall a. a -> Maybe a
Just SValue MatlabCode
e)
setDec :: SVariable MatlabCode
-> MatlabCode ScopeData -> MS (MatlabCode (Doc, Terminator))
setDec = SVariable MatlabCode
-> MatlabCode ScopeData -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
DeclStatement r smt =>
SVariable r -> r ScopeData -> MS (r smt)
varDec
setDecDef :: SVariable MatlabCode
-> MatlabCode ScopeData
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
setDecDef = SVariable MatlabCode
-> MatlabCode ScopeData
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
DeclStatement r smt =>
SVariable r -> r ScopeData -> SValue r -> MS (r smt)
varDecDef
listDec :: Integer
-> SVariable MatlabCode
-> MatlabCode ScopeData
-> MS (MatlabCode (Doc, Terminator))
listDec Integer
_ = SVariable MatlabCode
-> MatlabCode ScopeData -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
DeclStatement r smt =>
SVariable r -> r ScopeData -> MS (r smt)
varDec
listDecDef :: SVariable MatlabCode
-> MatlabCode ScopeData
-> [SValue MatlabCode]
-> MS (MatlabCode (Doc, Terminator))
listDecDef = SVariable MatlabCode
-> MatlabCode ScopeData
-> [SValue MatlabCode]
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(DeclStatement r smt, Literal r, VariableElim r) =>
SVariable r -> r ScopeData -> [SValue r] -> MS (r smt)
CP.listDecDef
arrayDec :: Integer
-> SValue MatlabCode
-> SVariable MatlabCode
-> MatlabCode ScopeData
-> MS (MatlabCode (Doc, Terminator))
arrayDec Integer
_ SValue MatlabCode
_ = SVariable MatlabCode
-> MatlabCode ScopeData -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
DeclStatement r smt =>
SVariable r -> r ScopeData -> MS (r smt)
varDec
arrayDecDef :: SVariable MatlabCode
-> MatlabCode ScopeData
-> [SValue MatlabCode]
-> MS (MatlabCode (Doc, Terminator))
arrayDecDef = SVariable MatlabCode
-> MatlabCode ScopeData
-> [SValue MatlabCode]
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
DeclStatement r smt =>
SVariable r -> r ScopeData -> [SValue r] -> MS (r smt)
listDecDef
constDecDef :: SVariable MatlabCode
-> MatlabCode ScopeData
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
constDecDef = SVariable MatlabCode
-> MatlabCode ScopeData
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
DeclStatement r smt =>
SVariable r -> r ScopeData -> SValue r -> MS (r smt)
varDecDef
funcDecDef :: SVariable MatlabCode
-> MatlabCode ScopeData
-> [SVariable MatlabCode]
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
funcDecDef = SVariable MatlabCode
-> MatlabCode ScopeData
-> [SVariable MatlabCode]
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) vis smt md.
ProcRenderSym r vis smt md =>
SVariable r
-> r ScopeData -> [SVariable r] -> MS (r Doc) -> MS (r smt)
A.funcDecDef
instance IOStatement MatlabCode (Doc, Terminator) where
print :: SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
print = Bool
-> Maybe (SValue MatlabCode)
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(InternalIOStmt r smt, SharedStatement r smt, TypeElim r) =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MS (r smt)
G.print Bool
False Maybe (SValue MatlabCode)
forall a. Maybe a
Nothing SValue MatlabCode
forall (r :: * -> *). RenderValue r => SValue r
printFunc
printLn :: SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
printLn = Bool
-> Maybe (SValue MatlabCode)
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(InternalIOStmt r smt, SharedStatement r smt, TypeElim r) =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MS (r smt)
G.print Bool
True Maybe (SValue MatlabCode)
forall a. Maybe a
Nothing SValue MatlabCode
forall (r :: * -> *). RenderValue r => SValue r
printLnFunc
printStr :: Label -> MS (MatlabCode (Doc, Terminator))
printStr = Bool
-> Maybe (SValue MatlabCode)
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(InternalIOStmt r smt, SharedStatement r smt, TypeElim r) =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MS (r smt)
G.print Bool
False Maybe (SValue MatlabCode)
forall a. Maybe a
Nothing SValue MatlabCode
forall (r :: * -> *). RenderValue r => SValue r
printFunc (SValue MatlabCode -> MS (MatlabCode (Doc, Terminator)))
-> (Label -> SValue MatlabCode)
-> Label
-> MS (MatlabCode (Doc, Terminator))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Label -> SValue MatlabCode
forall (r :: * -> *). Literal r => Label -> SValue r
litString
printStrLn :: Label -> MS (MatlabCode (Doc, Terminator))
printStrLn = Bool
-> Maybe (SValue MatlabCode)
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(InternalIOStmt r smt, SharedStatement r smt, TypeElim r) =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MS (r smt)
G.print Bool
True Maybe (SValue MatlabCode)
forall a. Maybe a
Nothing SValue MatlabCode
forall (r :: * -> *). RenderValue r => SValue r
printLnFunc (SValue MatlabCode -> MS (MatlabCode (Doc, Terminator)))
-> (Label -> SValue MatlabCode)
-> Label
-> MS (MatlabCode (Doc, Terminator))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Label -> SValue MatlabCode
forall (r :: * -> *). Literal r => Label -> SValue r
litString
printFile :: SValue MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
printFile SValue MatlabCode
f = Bool
-> Maybe (SValue MatlabCode)
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(InternalIOStmt r smt, SharedStatement r smt, TypeElim r) =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MS (r smt)
G.print Bool
False (SValue MatlabCode -> Maybe (SValue MatlabCode)
forall a. a -> Maybe a
Just SValue MatlabCode
f) SValue MatlabCode
forall (r :: * -> *). RenderValue r => SValue r
printFunc
printFileLn :: SValue MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
printFileLn SValue MatlabCode
f = Bool
-> Maybe (SValue MatlabCode)
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(InternalIOStmt r smt, SharedStatement r smt, TypeElim r) =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MS (r smt)
G.print Bool
True (SValue MatlabCode -> Maybe (SValue MatlabCode)
forall a. a -> Maybe a
Just SValue MatlabCode
f) SValue MatlabCode
forall (r :: * -> *). RenderValue r => SValue r
printLnFunc
printFileStr :: SValue MatlabCode -> Label -> MS (MatlabCode (Doc, Terminator))
printFileStr SValue MatlabCode
f = SValue MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
IOStatement r smt =>
SValue r -> SValue r -> MS (r smt)
printFile SValue MatlabCode
f (SValue MatlabCode -> MS (MatlabCode (Doc, Terminator)))
-> (Label -> SValue MatlabCode)
-> Label
-> MS (MatlabCode (Doc, Terminator))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Label -> SValue MatlabCode
forall (r :: * -> *). Literal r => Label -> SValue r
litString
printFileStrLn :: SValue MatlabCode -> Label -> MS (MatlabCode (Doc, Terminator))
printFileStrLn SValue MatlabCode
f = SValue MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
IOStatement r smt =>
SValue r -> SValue r -> MS (r smt)
printFileLn SValue MatlabCode
f (SValue MatlabCode -> MS (MatlabCode (Doc, Terminator)))
-> (Label -> SValue MatlabCode)
-> Label
-> MS (MatlabCode (Doc, Terminator))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Label -> SValue MatlabCode
forall (r :: * -> *). Literal r => Label -> SValue r
litString
getInput :: SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
getInput = SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall a. HasCallStack => a
undefined
discardInput :: MS (MatlabCode (Doc, Terminator))
discardInput = MS (MatlabCode (Doc, Terminator))
forall a. HasCallStack => a
undefined
getFileInput :: SValue MatlabCode
-> SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
getFileInput SValue MatlabCode
f = SValue MatlabCode
-> SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
mlInput (SValue MatlabCode -> SValue MatlabCode
mlReadLine SValue MatlabCode
f)
discardFileInput :: SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
discardFileInput SValue MatlabCode
f = SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
StatementSym r smt =>
SValue r -> MS (r smt)
valStmt (SValue MatlabCode -> SValue MatlabCode
mlReadLine SValue MatlabCode
f)
openFileR :: SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
openFileR SVariable MatlabCode
f SValue MatlabCode
n = SVariable MatlabCode
f SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
AssignStatement r smt =>
SVariable r -> SValue r -> MS (r smt)
&= PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"fopen" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
infile [SValue MatlabCode
n, Label -> SValue MatlabCode
forall (r :: * -> *). Literal r => Label -> SValue r
litString Label
"r"]
openFileW :: SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
openFileW SVariable MatlabCode
f SValue MatlabCode
n = SVariable MatlabCode
f SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
AssignStatement r smt =>
SVariable r -> SValue r -> MS (r smt)
&= PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"fopen" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
outfile [SValue MatlabCode
n, Label -> SValue MatlabCode
forall (r :: * -> *). Literal r => Label -> SValue r
litString Label
"w"]
openFileA :: SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
openFileA SVariable MatlabCode
f SValue MatlabCode
n = SVariable MatlabCode
f SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
AssignStatement r smt =>
SVariable r -> SValue r -> MS (r smt)
&= PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"fopen" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
outfile [SValue MatlabCode
n, Label -> SValue MatlabCode
forall (r :: * -> *). Literal r => Label -> SValue r
litString Label
"a"]
closeFile :: SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
closeFile SValue MatlabCode
f = SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
StatementSym r smt =>
SValue r -> MS (r smt)
valStmt (SValue MatlabCode -> MS (MatlabCode (Doc, Terminator)))
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall a b. (a -> b) -> a -> b
$ PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"fclose" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
void [SValue MatlabCode
f]
getFileInputLine :: SValue MatlabCode
-> SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
getFileInputLine = SValue MatlabCode
-> SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
IOStatement r smt =>
SValue r -> SVariable r -> MS (r smt)
getFileInput
discardFileLine :: SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
discardFileLine = SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
IOStatement r smt =>
SValue r -> MS (r smt)
discardFileInput
getFileInputAll :: SValue MatlabCode
-> SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
getFileInputAll = SValue MatlabCode
-> SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall a. HasCallStack => a
undefined
instance StringStatement MatlabCode (Doc, Terminator) where
stringSplit :: Char
-> SVariable MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
stringSplit = Char
-> SVariable MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
forall a. HasCallStack => a
undefined
stringListVals :: [SVariable MatlabCode]
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
stringListVals = [SVariable MatlabCode]
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall a. HasCallStack => a
undefined
stringListLists :: [SVariable MatlabCode]
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
stringListLists = [SVariable MatlabCode]
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall a. HasCallStack => a
undefined
instance FunctionSym MatlabCode where
instance FuncAppStatement MatlabCode (Doc, Terminator) where
inOutCall :: InOutCall MatlabCode (Doc, Terminator)
inOutCall = PosCall MatlabCode -> InOutCall MatlabCode (Doc, Terminator)
forall (r :: * -> *) smt.
(InternalAssignStmt r smt, StatementSym r smt, VariableValue r) =>
(Label -> VS (r TypeData) -> [SValue r] -> SValue r)
-> Label
-> [SValue r]
-> [SVariable r]
-> [SVariable r]
-> MS (r smt)
CP.inOutCall PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp
extInOutCall :: Label -> InOutCall MatlabCode (Doc, Terminator)
extInOutCall = Label -> InOutCall MatlabCode (Doc, Terminator)
forall a. HasCallStack => a
undefined
instance CommentStatement MatlabCode (Doc, Terminator) where
comment :: Label -> MS (MatlabCode (Doc, Terminator))
comment = Doc -> Label -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
RenderStatement r smt =>
Doc -> Label -> MS (r smt)
G.comment Doc
mlCmtStart
instance ControlStatement MatlabCode (Doc, Terminator) where
break :: MS (MatlabCode (Doc, Terminator))
break = Doc -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
RenderStatement r smt =>
Doc -> MS (r smt)
mkStmtNoEnd Doc
R.break
continue :: MS (MatlabCode (Doc, Terminator))
continue = Doc -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
RenderStatement r smt =>
Doc -> MS (r smt)
mkStmtNoEnd Doc
R.continue
returnStmt :: SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
returnStmt SValue MatlabCode
v' = do
MatlabCode Value
v <- LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Value))
MethodState
ValueState
-> SValue MatlabCode
-> StateT MethodState Identity (MatlabCode Value)
forall c.
LensLike'
(Zoomed (StateT ValueState Identity) c) MethodState ValueState
-> StateT ValueState Identity c -> StateT MethodState Identity c
forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Value))
MethodState
ValueState
(ValueState -> Focusing Identity (MatlabCode Value) ValueState)
-> MethodState -> Focusing Identity (MatlabCode Value) MethodState
Lens' MethodState ValueState
lensMStoVS SValue MatlabCode
v'
Label -> VS (MatlabCode TypeData) -> SVariable MatlabCode
forall (r :: * -> *).
VariableSym r =>
Label -> VS (r TypeData) -> SVariable r
var Label
mlRet (MatlabCode TypeData -> VS (MatlabCode TypeData)
forall a s. a -> State s a
toState (MatlabCode Value -> MatlabCode TypeData
forall (r :: * -> *). ValueSym r => r Value -> r TypeData
valueType MatlabCode Value
v)) SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
AssignStatement r smt =>
SVariable r -> SValue r -> MS (r smt)
&= SValue MatlabCode
v'
throw :: Label -> MS (MatlabCode (Doc, Terminator))
throw Label
errMsg = SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
StatementSym r smt =>
SValue r -> MS (r smt)
valStmt (SValue MatlabCode -> MS (MatlabCode (Doc, Terminator)))
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall a b. (a -> b) -> a -> b
$ PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"error" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
void [Label -> SValue MatlabCode
forall (r :: * -> *). Literal r => Label -> SValue r
litString Label
errMsg]
ifCond :: [(SValue MatlabCode, MS (MatlabCode Doc))]
-> MS (MatlabCode Doc) -> MS (MatlabCode (Doc, Terminator))
ifCond = (Doc -> Doc)
-> Doc
-> OptionalSpace
-> Doc
-> Doc
-> Doc
-> [(SValue MatlabCode, MS (MatlabCode Doc))]
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(BodyElim r, RenderStatement r smt, ValueElim r) =>
(Doc -> Doc)
-> Doc
-> OptionalSpace
-> Doc
-> Doc
-> Doc
-> [(SValue r, MS (r Doc))]
-> MS (r Doc)
-> MS (r smt)
G.ifCond Doc -> Doc
forall a. a -> a
id Doc
empty (Doc -> OptionalSpace
OSpace Doc
empty) Doc
R.elseIfLabel Doc
empty Doc
mlEnd
switch :: SValue MatlabCode
-> [(SValue MatlabCode, MS (MatlabCode Doc))]
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
switch = SValue MatlabCode
-> [(SValue MatlabCode, MS (MatlabCode Doc))]
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(ControlStatement r smt, Comparison r) =>
SValue r -> [(SValue r, MS (r Doc))] -> MS (r Doc) -> MS (r smt)
switchAsIf
ifExists :: SValue MatlabCode
-> MS (MatlabCode Doc)
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
ifExists = SValue MatlabCode
-> MS (MatlabCode Doc)
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(ControlStatement r smt, ValueExpression r) =>
SValue r -> MS (r Doc) -> MS (r Doc) -> MS (r smt)
M.ifExists
for :: MS (MatlabCode (Doc, Terminator))
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
for MS (MatlabCode (Doc, Terminator))
_ SValue MatlabCode
_ MS (MatlabCode (Doc, Terminator))
_ MS (MatlabCode Doc)
_ = Label -> MS (MatlabCode (Doc, Terminator))
forall a. HasCallStack => Label -> a
error Label
"MATLAB does not support C-style for loops; use forRange"
forRange :: SVariable MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
forRange SVariable MatlabCode
i SValue MatlabCode
initv SValue MatlabCode
finalv SValue MatlabCode
stepv = SVariable MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
ControlStatement r smt =>
SVariable r -> SValue r -> MS (r Doc) -> MS (r smt)
forEach SVariable MatlabCode
i (SValue MatlabCode
-> SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *) vis smt md.
CommonRenderSym r vis smt md =>
SValue r -> SValue r -> SValue r -> SValue r
mlRange SValue MatlabCode
initv SValue MatlabCode
finalv SValue MatlabCode
stepv)
forEach :: SVariable MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
forEach = (MatlabCode Variable -> MatlabCode Value -> MatlabCode Doc -> Doc)
-> SVariable MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
RenderStatement r smt =>
(r Variable -> r Value -> r Doc -> Doc)
-> SVariable r -> SValue r -> MS (r Doc) -> MS (r smt)
CS.forEach' MatlabCode Variable -> MatlabCode Value -> MatlabCode Doc -> Doc
forall (r :: * -> *) vis smt md.
CommonRenderSym r vis smt md =>
r Variable -> r Value -> r Doc -> Doc
mlForEach
while :: SValue MatlabCode
-> MS (MatlabCode Doc) -> MS (MatlabCode (Doc, Terminator))
while = (Doc -> Doc)
-> Doc
-> Doc
-> SValue MatlabCode
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
(BodyElim r, RenderStatement r smt, ValueElim r) =>
(Doc -> Doc) -> Doc -> Doc -> SValue r -> MS (r Doc) -> MS (r smt)
C.while Doc -> Doc
forall a. a -> a
id Doc
empty Doc
mlEnd
tryCatch :: MS (MatlabCode Doc)
-> MS (MatlabCode Doc) -> MS (MatlabCode (Doc, Terminator))
tryCatch = (MatlabCode Doc -> MatlabCode Doc -> Doc)
-> MS (MatlabCode Doc)
-> MS (MatlabCode Doc)
-> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
RenderStatement r smt =>
(r Doc -> r Doc -> Doc) -> MS (r Doc) -> MS (r Doc) -> MS (r smt)
G.tryCatch MatlabCode Doc -> MatlabCode Doc -> Doc
forall (r :: * -> *) vis smt md.
CommonRenderSym r vis smt md =>
r Doc -> r Doc -> Doc
mlTryCatch
assert :: SValue MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
assert SValue MatlabCode
cond SValue MatlabCode
errMsg = SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
StatementSym r smt =>
SValue r -> MS (r smt)
valStmt (SValue MatlabCode -> MS (MatlabCode (Doc, Terminator)))
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall a b. (a -> b) -> a -> b
$ PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"assert" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
void [SValue MatlabCode
cond, SValue MatlabCode
errMsg]
instance VisibilitySym MatlabCode Doc where
private :: MatlabCode Doc
private = Doc -> MatlabCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
empty
public :: MatlabCode Doc
public = Doc -> MatlabCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
empty
instance RenderVisibility MatlabCode Doc where
visibilityFromData :: VisibilityTag -> Doc -> MatlabCode Doc
visibilityFromData = VisibilityTag -> Doc -> MatlabCode Doc
forall a. HasCallStack => a
undefined
instance VisibilityElim MatlabCode Doc where
visibility :: MatlabCode Doc -> Doc
visibility = MatlabCode Doc -> Doc
forall a. MatlabCode a -> a
unMLC
instance MethodTypeSym MatlabCode where
mType :: VS (MatlabCode TypeData) -> MSMthdType MatlabCode
mType = LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode TypeData))
MethodState
ValueState
-> VS (MatlabCode TypeData) -> MSMthdType MatlabCode
forall c.
LensLike'
(Zoomed (StateT ValueState Identity) c) MethodState ValueState
-> StateT ValueState Identity c -> StateT MethodState Identity c
forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode TypeData))
MethodState
ValueState
(ValueState -> Focusing Identity (MatlabCode TypeData) ValueState)
-> MethodState
-> Focusing Identity (MatlabCode TypeData) MethodState
Lens' MethodState ValueState
lensMStoVS
instance ParameterSym MatlabCode where
param :: SVariable MatlabCode -> MS (MatlabCode ParamData)
param = (MatlabCode Variable -> Doc)
-> SVariable MatlabCode -> MS (MatlabCode ParamData)
forall (r :: * -> *).
(RenderParam r, VariableElim r) =>
(r Variable -> Doc) -> SVariable r -> MS (r ParamData)
G.param MatlabCode Variable -> Doc
mlParam
pointerParam :: SVariable MatlabCode -> MS (MatlabCode ParamData)
pointerParam = SVariable MatlabCode -> MS (MatlabCode ParamData)
forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MS (r ParamData)
param
instance RenderParam MatlabCode where
paramFromData :: SVariable MatlabCode -> Doc -> MS (MatlabCode ParamData)
paramFromData SVariable MatlabCode
v' Doc
d = do
MatlabCode Variable
v <- LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Variable))
MethodState
ValueState
-> SVariable MatlabCode
-> StateT MethodState Identity (MatlabCode Variable)
forall c.
LensLike'
(Zoomed (StateT ValueState Identity) c) MethodState ValueState
-> StateT ValueState Identity c -> StateT MethodState Identity c
forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Variable))
MethodState
ValueState
(ValueState -> Focusing Identity (MatlabCode Variable) ValueState)
-> MethodState
-> Focusing Identity (MatlabCode Variable) MethodState
Lens' MethodState ValueState
lensMStoVS SVariable MatlabCode
v'
MatlabCode ParamData -> MS (MatlabCode ParamData)
forall a s. a -> State s a
toState (MatlabCode ParamData -> MS (MatlabCode ParamData))
-> MatlabCode ParamData -> MS (MatlabCode ParamData)
forall a b. (a -> b) -> a -> b
$ (Variable -> Doc -> ParamData)
-> MatlabCode Variable -> MatlabCode Doc -> MatlabCode ParamData
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues Variable -> Doc -> ParamData
pd MatlabCode Variable
v (Doc -> MatlabCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
d)
instance ParamElim MatlabCode where
parameterName :: MatlabCode ParamData -> Label
parameterName = MatlabCode Variable -> Label
forall (r :: * -> *). VariableElim r => r Variable -> Label
variableName (MatlabCode Variable -> Label)
-> (MatlabCode ParamData -> MatlabCode Variable)
-> MatlabCode ParamData
-> Label
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParamData -> Variable)
-> MatlabCode ParamData -> MatlabCode Variable
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ParamData -> Variable
paramVar
parameterType :: MatlabCode ParamData -> MatlabCode TypeData
parameterType = MatlabCode Variable -> MatlabCode TypeData
forall (r :: * -> *). VariableElim r => r Variable -> r TypeData
variableType (MatlabCode Variable -> MatlabCode TypeData)
-> (MatlabCode ParamData -> MatlabCode Variable)
-> MatlabCode ParamData
-> MatlabCode TypeData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParamData -> Variable)
-> MatlabCode ParamData -> MatlabCode Variable
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ParamData -> Variable
paramVar
parameter :: MatlabCode ParamData -> Doc
parameter = ParamData -> Doc
paramDoc (ParamData -> Doc)
-> (MatlabCode ParamData -> ParamData)
-> MatlabCode ParamData
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode ParamData -> ParamData
forall a. MatlabCode a -> a
unMLC
instance MethodSym MatlabCode Doc (Doc, Terminator) MethodData where
docMain :: MS (MatlabCode Doc) -> MS (MatlabCode MethodData)
docMain = MS (MatlabCode Doc) -> MS (MatlabCode MethodData)
forall (r :: * -> *) vis smt md.
MethodSym r vis smt md =>
MS (r Doc) -> MS (r md)
mainFunction
function :: Label
-> MatlabCode Doc
-> VS (MatlabCode TypeData)
-> [MS (MatlabCode ParamData)]
-> MS (MatlabCode Doc)
-> MS (MatlabCode MethodData)
function = Label
-> MatlabCode Doc
-> VS (MatlabCode TypeData)
-> [MS (MatlabCode ParamData)]
-> MS (MatlabCode Doc)
-> MS (MatlabCode MethodData)
forall (r :: * -> *) vis md.
ProcRenderMethod r vis md =>
Label
-> r vis
-> VS (r TypeData)
-> [MS (r ParamData)]
-> MS (r Doc)
-> MS (r md)
A.function
mainFunction :: MS (MatlabCode Doc) -> MS (MatlabCode MethodData)
mainFunction = MS (MatlabCode Doc) -> MS (MatlabCode MethodData)
forall (r :: * -> *) md.
(BodyElim r, RenderMethod r md) =>
MS (r Doc) -> MS (r md)
CP.mainBody
docFunc :: Label
-> [Label]
-> Maybe Label
-> MS (MatlabCode MethodData)
-> MS (MatlabCode MethodData)
docFunc = FuncDocRenderer
-> Label
-> [Label]
-> Maybe Label
-> MS (MatlabCode MethodData)
-> MS (MatlabCode MethodData)
forall (r :: * -> *) md.
RenderMethod r md =>
FuncDocRenderer
-> Label -> [Label] -> Maybe Label -> MS (r md) -> MS (r md)
G.docFunc FuncDocRenderer
CP.functionDoc
inOutFunc :: Label -> MatlabCode Doc -> InOutFunc MatlabCode MethodData
inOutFunc Label
n MatlabCode Doc
_ [SVariable MatlabCode]
ins [SVariable MatlabCode]
outs [SVariable MatlabCode]
both MS (MatlabCode Doc)
b = do
[MatlabCode ParamData]
pms <- (SVariable MatlabCode -> MS (MatlabCode ParamData))
-> [SVariable MatlabCode]
-> StateT MethodState Identity [MatlabCode ParamData]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM SVariable MatlabCode -> MS (MatlabCode ParamData)
forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MS (r ParamData)
param ([SVariable MatlabCode]
both [SVariable MatlabCode]
-> [SVariable MatlabCode] -> [SVariable MatlabCode]
forall a. [a] -> [a] -> [a]
++ [SVariable MatlabCode]
ins)
[MatlabCode Variable]
rets <- (SVariable MatlabCode
-> StateT MethodState Identity (MatlabCode Variable))
-> [SVariable MatlabCode]
-> StateT MethodState Identity [MatlabCode Variable]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Variable))
MethodState
ValueState
-> SVariable MatlabCode
-> StateT MethodState Identity (MatlabCode Variable)
forall c.
LensLike'
(Zoomed (StateT ValueState Identity) c) MethodState ValueState
-> StateT ValueState Identity c -> StateT MethodState Identity c
forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Variable))
MethodState
ValueState
(ValueState -> Focusing Identity (MatlabCode Variable) ValueState)
-> MethodState
-> Focusing Identity (MatlabCode Variable) MethodState
Lens' MethodState ValueState
lensMStoVS) ([SVariable MatlabCode]
both [SVariable MatlabCode]
-> [SVariable MatlabCode] -> [SVariable MatlabCode]
forall a. [a] -> [a] -> [a]
++ [SVariable MatlabCode]
outs)
MatlabCode Doc
bod <- MS (MatlabCode Doc)
b
MatlabCode MethodData -> MS (MatlabCode MethodData)
forall a. a -> StateT MethodState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (MatlabCode MethodData -> MS (MatlabCode MethodData))
-> MatlabCode MethodData -> MS (MatlabCode MethodData)
forall a b. (a -> b) -> a -> b
$ MethodData -> MatlabCode MethodData
forall (r :: * -> *) a. Monad r => a -> r a
toCode (MethodData -> MatlabCode MethodData)
-> MethodData -> MatlabCode MethodData
forall a b. (a -> b) -> a -> b
$ Doc -> MethodData
mthd (Doc -> MethodData) -> Doc -> MethodData
forall a b. (a -> b) -> a -> b
$ Label -> [Doc] -> [MatlabCode ParamData] -> Doc -> Doc
forall (r :: * -> *).
ParamElim r =>
Label -> [Doc] -> [r ParamData] -> Doc -> Doc
mlFuncDoc Label
n ((MatlabCode Variable -> Doc) -> [MatlabCode Variable] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map MatlabCode Variable -> Doc
forall (r :: * -> *). InternalVarElim r => r Variable -> Doc
RC.variable [MatlabCode Variable]
rets) [MatlabCode ParamData]
pms (MatlabCode Doc -> Doc
forall (r :: * -> *). BodyElim r => r Doc -> Doc
RC.body MatlabCode Doc
bod)
docInOutFunc :: Label -> MatlabCode Doc -> DocInOutFunc MatlabCode MethodData
docInOutFunc Label
n MatlabCode Doc
s = FuncDocRenderer
-> InOutFunc MatlabCode MethodData
-> DocInOutFunc MatlabCode MethodData
forall (r :: * -> *) md.
RenderMethod r md =>
FuncDocRenderer
-> ([SVariable r]
-> [SVariable r] -> [SVariable r] -> MS (r Doc) -> MS (r md))
-> Label
-> [(Label, SVariable r)]
-> [(Label, SVariable r)]
-> [(Label, SVariable r)]
-> MS (r Doc)
-> MS (r md)
CP.docInOutFunc' FuncDocRenderer
CP.functionDoc (Label -> MatlabCode Doc -> InOutFunc MatlabCode MethodData
forall (r :: * -> *) vis smt md.
MethodSym r vis smt md =>
Label -> r vis -> InOutFunc r md
inOutFunc Label
n MatlabCode Doc
s)
instance RenderMethod MatlabCode MethodData where
commentedFunc :: MS (MatlabCode Doc)
-> MS (MatlabCode MethodData) -> MS (MatlabCode MethodData)
commentedFunc MS (MatlabCode Doc)
cmt MS (MatlabCode MethodData)
m = (MatlabCode MethodData
-> MatlabCode (Doc -> Doc) -> MatlabCode MethodData)
-> MS (MatlabCode MethodData)
-> State MethodState (MatlabCode (Doc -> Doc))
-> MS (MatlabCode MethodData)
forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues ((MethodData -> (Doc -> Doc) -> MethodData)
-> MatlabCode MethodData
-> MatlabCode (Doc -> Doc)
-> MatlabCode MethodData
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues MethodData -> (Doc -> Doc) -> MethodData
updateMthd) MS (MatlabCode MethodData)
m
((MatlabCode Doc -> MatlabCode (Doc -> Doc))
-> MS (MatlabCode Doc)
-> State MethodState (MatlabCode (Doc -> Doc))
forall a b s. (a -> b) -> State s a -> State s b
onStateValue ((Doc -> Doc -> Doc) -> MatlabCode Doc -> MatlabCode (Doc -> Doc)
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue Doc -> Doc -> Doc
R.commentedItem) MS (MatlabCode Doc)
cmt)
mthdFromData :: VisibilityTag -> Doc -> MS (MatlabCode MethodData)
mthdFromData VisibilityTag
_ Doc
d = MatlabCode MethodData -> MS (MatlabCode MethodData)
forall a s. a -> State s a
toState (MatlabCode MethodData -> MS (MatlabCode MethodData))
-> MatlabCode MethodData -> MS (MatlabCode MethodData)
forall a b. (a -> b) -> a -> b
$ MethodData -> MatlabCode MethodData
forall (r :: * -> *) a. Monad r => a -> r a
toCode (MethodData -> MatlabCode MethodData)
-> MethodData -> MatlabCode MethodData
forall a b. (a -> b) -> a -> b
$ Doc -> MethodData
mthd Doc
d
instance ProcRenderMethod MatlabCode Doc MethodData where
intFunc :: Bool
-> Label
-> MatlabCode Doc
-> MSMthdType MatlabCode
-> [MS (MatlabCode ParamData)]
-> MS (MatlabCode Doc)
-> MS (MatlabCode MethodData)
intFunc Bool
_ Label
n MatlabCode Doc
_ MSMthdType MatlabCode
t [MS (MatlabCode ParamData)]
ps MS (MatlabCode Doc)
b = do
[MatlabCode ParamData]
pms <- [MS (MatlabCode ParamData)]
-> StateT MethodState Identity [MatlabCode ParamData]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence [MS (MatlabCode ParamData)]
ps
MatlabCode TypeData
tp <- MSMthdType MatlabCode
t
MatlabCode Doc
bod <- MS (MatlabCode Doc)
b
let outs :: [Doc]
outs = [Label -> Doc
text Label
mlRet | TypeData -> CodeType
cType (MatlabCode TypeData -> TypeData
forall a. MatlabCode a -> a
unMLC MatlabCode TypeData
tp) CodeType -> CodeType -> Bool
forall a. Eq a => a -> a -> Bool
/= CodeType
Void]
MatlabCode MethodData -> MS (MatlabCode MethodData)
forall a. a -> StateT MethodState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (MatlabCode MethodData -> MS (MatlabCode MethodData))
-> MatlabCode MethodData -> MS (MatlabCode MethodData)
forall a b. (a -> b) -> a -> b
$ MethodData -> MatlabCode MethodData
forall (r :: * -> *) a. Monad r => a -> r a
toCode (MethodData -> MatlabCode MethodData)
-> MethodData -> MatlabCode MethodData
forall a b. (a -> b) -> a -> b
$ Doc -> MethodData
mthd (Doc -> MethodData) -> Doc -> MethodData
forall a b. (a -> b) -> a -> b
$ Label -> [Doc] -> [MatlabCode ParamData] -> Doc -> Doc
forall (r :: * -> *).
ParamElim r =>
Label -> [Doc] -> [r ParamData] -> Doc -> Doc
mlFuncDoc Label
n [Doc]
outs [MatlabCode ParamData]
pms (MatlabCode Doc -> Doc
forall (r :: * -> *). BodyElim r => r Doc -> Doc
RC.body MatlabCode Doc
bod)
instance MethodElim MatlabCode MethodData where
method :: MatlabCode MethodData -> Doc
method = MethodData -> Doc
mthdDoc (MethodData -> Doc)
-> (MatlabCode MethodData -> MethodData)
-> MatlabCode MethodData
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode MethodData -> MethodData
forall a. MatlabCode a -> a
unMLC
instance ModuleSym MatlabCode Doc (Doc, Terminator) MethodData where
buildModule :: Label
-> [Label]
-> [MS (MatlabCode MethodData)]
-> FS (MatlabCode Module)
buildModule Label
n [Label]
_ = Label
-> FS Doc
-> FS Doc
-> [MS (MatlabCode MethodData)]
-> FS (MatlabCode Module)
forall (r :: * -> *) md.
(MethodElim r md, RenderMod r) =>
Label -> FS Doc -> FS Doc -> [MS (r md)] -> FS (r Module)
A.buildModule Label
n (Label -> FS Doc
mlMainFunc Label
n) (Doc -> FS Doc
forall a. a -> StateT FileState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
empty)
instance RenderMod MatlabCode where
modFromData :: Label -> FS Doc -> FS (MatlabCode Module)
modFromData Label
n = Label
-> (Doc -> MatlabCode Module) -> FS Doc -> FS (MatlabCode Module)
forall (r :: * -> *).
Label -> (Doc -> r Module) -> FS Doc -> FS (r Module)
A.modFromData Label
n (Module -> MatlabCode Module
forall (r :: * -> *) a. Monad r => a -> r a
toCode (Module -> MatlabCode Module)
-> (Doc -> Module) -> Doc -> MatlabCode Module
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Label -> Doc -> Module
md Label
n)
updateModuleDoc :: (Doc -> Doc) -> MatlabCode Module -> MatlabCode Module
updateModuleDoc Doc -> Doc
f = (Module -> Module) -> MatlabCode Module -> MatlabCode Module
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ((Doc -> Doc) -> Module -> Module
updateMod Doc -> Doc
f)
instance ModuleElim MatlabCode where
module' :: MatlabCode Module -> Doc
module' = Module -> Doc
modDoc (Module -> Doc)
-> (MatlabCode Module -> Module) -> MatlabCode Module -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode Module -> Module
forall a. MatlabCode a -> a
unMLC
instance BlockCommentSym MatlabCode where
blockComment :: [Label] -> MatlabCode Doc
blockComment [Label]
lns = Doc -> MatlabCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode (Doc -> MatlabCode Doc) -> Doc -> MatlabCode Doc
forall a b. (a -> b) -> a -> b
$ [Label] -> Doc
mlLineCmt [Label]
lns
docComment :: forall a. State a [Label] -> State a (MatlabCode Doc)
docComment = ([Label] -> MatlabCode Doc)
-> State a [Label] -> State a (MatlabCode Doc)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue (Doc -> MatlabCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode (Doc -> MatlabCode Doc)
-> ([Label] -> Doc) -> [Label] -> MatlabCode Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Label] -> Doc
mlLineCmt)
instance BlockCommentElim MatlabCode where
blockComment' :: MatlabCode Doc -> Doc
blockComment' = MatlabCode Doc -> Doc
forall a. MatlabCode a -> a
unMLC
mlName, mlVersion :: String
mlName :: Label
mlName = Label
"MATLAB"
mlVersion :: Label
mlVersion = Label
"R2024b"
mlExt :: String
mlExt :: Label
mlExt = Label
"m"
mlRet :: String
mlRet :: Label
mlRet = Label
"result"
mlTy :: CodeType -> String -> VS (MatlabCode TypeData)
mlTy :: CodeType -> Label -> VS (MatlabCode TypeData)
mlTy CodeType
c Label
s = CodeType -> Label -> Doc -> VS (MatlabCode TypeData)
forall (r :: * -> *).
Monad r =>
CodeType -> Label -> Doc -> VS (r TypeData)
typeFromData CodeType
c Label
s (Label -> Doc
text Label
s)
mlParam :: MatlabCode Variable -> Doc
mlParam :: MatlabCode Variable -> Doc
mlParam = MatlabCode Variable -> Doc
forall (r :: * -> *). InternalVarElim r => r Variable -> Doc
RC.variable
mlFuncDoc :: (ParamElim r) => Label -> [Doc] ->
[r ParamData] -> Doc -> Doc
mlFuncDoc :: forall (r :: * -> *).
ParamElim r =>
Label -> [Doc] -> [r ParamData] -> Doc -> Doc
mlFuncDoc Label
n [Doc]
outs [r ParamData]
pms Doc
bod =
[Doc] -> Doc
vcat [Label -> Doc
text Label
"function" Doc -> Doc -> Doc
<+> (Doc
retDoc Doc -> Doc -> Doc
<> Label -> Doc
text Label
n) Doc -> Doc -> Doc
<> Doc -> Doc
parens ([r ParamData] -> Doc
forall (r :: * -> *). ParamElim r => [r ParamData] -> Doc
R.parameterList [r ParamData]
pms),
Doc -> Doc
indent Doc
bod,
Label -> Doc
text Label
"end"]
where retDoc :: Doc
retDoc = case [Doc]
outs of
[] -> Doc
empty
[Doc
o] -> Doc
o Doc -> Doc -> Doc
<+> Doc
equals Doc -> Doc -> Doc
<> Label -> Doc
text Label
" "
[Doc]
os -> Doc -> Doc
brackets ([Doc] -> Doc
hcat (Doc -> [Doc] -> [Doc]
punctuate (Label -> Doc
text Label
", ") [Doc]
os)) Doc -> Doc -> Doc
<+> Doc
equals Doc -> Doc -> Doc
<> Label -> Doc
text Label
" "
mlCmtStart :: Doc
mlCmtStart :: Doc
mlCmtStart = Label -> Doc
text Label
"%"
mlLineCmt :: [String] -> Doc
mlLineCmt :: [Label] -> Doc
mlLineCmt = [Doc] -> Doc
vcat ([Doc] -> Doc) -> ([Label] -> [Doc]) -> [Label] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Label -> Doc) -> [Label] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map ((Doc
mlCmtStart Doc -> Doc -> Doc
<+>) (Doc -> Doc) -> (Label -> Doc) -> Label -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Label -> Doc
text)
mlPrintFunc :: SValue MatlabCode
mlPrintFunc :: SValue MatlabCode
mlPrintFunc = VS (MatlabCode TypeData) -> Doc -> SValue MatlabCode
forall (r :: * -> *).
RenderValue r =>
VS (r TypeData) -> Doc -> SValue r
mkStateVal VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
void (Label -> Doc
text Label
"fprintf")
mlMainFunc :: Label -> FS Doc
mlMainFunc :: Label -> FS Doc
mlMainFunc Label
n = do
Doc
b <- FS Doc
getMainDoc
Doc -> FS Doc
forall a. a -> StateT FileState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> FS Doc) -> Doc -> FS Doc
forall a b. (a -> b) -> a -> b
$ Doc -> Doc -> Doc
emptyIfEmpty Doc
b (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ [Doc] -> Doc
vcat
[Label -> Doc
text Label
"function" Doc -> Doc -> Doc
<+> Label -> Doc
text Label
n Doc -> Doc -> Doc
<> Doc -> Doc
parens (Label -> Doc
text Label
"varargin"),
Doc -> Doc
indent Doc
b,
Label -> Doc
text Label
"end"]
mlArg :: SValue MatlabCode -> SValue MatlabCode
mlArg :: SValue MatlabCode -> SValue MatlabCode
mlArg SValue MatlabCode
n' = do
MatlabCode Value
n <- SValue MatlabCode
n'
MatlabCode TypeData
s <- VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
string
MatlabCode TypeData -> Doc -> SValue MatlabCode
forall (r :: * -> *).
RenderValue r =>
r TypeData -> Doc -> SValue r
mkVal MatlabCode TypeData
s (Label -> Doc
text Label
"varargin" Doc -> Doc -> Doc
<> Doc -> Doc
braces (MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
n))
mlVecIndex :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
mlVecIndex :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
mlVecIndex SValue MatlabCode
v' SValue MatlabCode
i' = do
MatlabCode Value
v <- SValue MatlabCode
v'
MatlabCode Value
i <- SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *). IndexTranslator r => SValue r -> SValue r
intToIndex SValue MatlabCode
i'
MatlabCode TypeData
d <- VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
double
MatlabCode TypeData -> Doc -> SValue MatlabCode
forall (r :: * -> *).
RenderValue r =>
r TypeData -> Doc -> SValue r
mkVal MatlabCode TypeData
d (MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
v Doc -> Doc -> Doc
<> Doc -> Doc
parens (MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
i))
mlListType :: VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
mlListType :: VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
mlListType VS (MatlabCode TypeData)
t' = do
MatlabCode TypeData
t <- VS (MatlabCode TypeData)
t'
CodeType -> Label -> VS (MatlabCode TypeData)
mlTy (CodeType -> CodeType
List (CodeType -> CodeType) -> CodeType -> CodeType
forall a b. (a -> b) -> a -> b
$ MatlabCode TypeData -> CodeType
forall (r :: * -> *). TypeElim r => r TypeData -> CodeType
getCodeType MatlabCode TypeData
t) Label
"vector"
mlLitList :: VS (MatlabCode TypeData) -> [SValue MatlabCode] -> SValue MatlabCode
mlLitList :: VS (MatlabCode TypeData)
-> [SValue MatlabCode] -> SValue MatlabCode
mlLitList VS (MatlabCode TypeData)
t [SValue MatlabCode]
es = do
[MatlabCode Value]
elems <- [SValue MatlabCode]
-> StateT ValueState Identity [MatlabCode Value]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence [SValue MatlabCode]
es
VS (MatlabCode TypeData) -> Doc -> SValue MatlabCode
forall (r :: * -> *).
RenderValue r =>
VS (r TypeData) -> Doc -> SValue r
mkStateVal (VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall (r :: * -> *).
TypeSym r =>
VS (r TypeData) -> VS (r TypeData)
listType VS (MatlabCode TypeData)
t) (Doc -> Doc
brackets ([MatlabCode Value] -> Doc
forall (r :: * -> *). ValueElim r => [r Value] -> Doc
valueList [MatlabCode Value]
elems))
mlReadLine :: SValue MatlabCode -> SValue MatlabCode
mlReadLine :: SValue MatlabCode -> SValue MatlabCode
mlReadLine SValue MatlabCode
f = PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"fgetl" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
string [SValue MatlabCode
f]
mlInput :: SValue MatlabCode -> SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
mlInput :: SValue MatlabCode
-> SVariable MatlabCode -> MS (MatlabCode (Doc, Terminator))
mlInput SValue MatlabCode
inSrc SVariable MatlabCode
v = SVariable MatlabCode
v SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
AssignStatement r smt =>
SVariable r -> SValue r -> MS (r smt)
&= (SVariable MatlabCode
v SVariable MatlabCode
-> (MatlabCode Variable -> SValue MatlabCode) -> SValue MatlabCode
forall a b.
StateT ValueState Identity a
-> (a -> StateT ValueState Identity b)
-> StateT ValueState Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CodeType -> SValue MatlabCode
mlInput' (CodeType -> SValue MatlabCode)
-> (MatlabCode Variable -> CodeType)
-> MatlabCode Variable
-> SValue MatlabCode
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode TypeData -> CodeType
forall (r :: * -> *). TypeElim r => r TypeData -> CodeType
getCodeType (MatlabCode TypeData -> CodeType)
-> (MatlabCode Variable -> MatlabCode TypeData)
-> MatlabCode Variable
-> CodeType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatlabCode Variable -> MatlabCode TypeData
forall (r :: * -> *). VariableElim r => r Variable -> r TypeData
variableType)
where mlInput' :: CodeType -> SValue MatlabCode
mlInput' CodeType
Integer = PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"str2double" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
int [SValue MatlabCode
inSrc]
mlInput' CodeType
Float = PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"str2double" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
float [SValue MatlabCode
inSrc]
mlInput' CodeType
Double = PosCall MatlabCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp Label
"str2double" VS (MatlabCode TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
double [SValue MatlabCode
inSrc]
mlInput' CodeType
String = SValue MatlabCode
inSrc
mlInput' CodeType
_ = Label -> SValue MatlabCode
forall a. HasCallStack => Label -> a
error Label
"Attempt to read a value of unreadable type"
mlPrint :: Bool -> Maybe (SValue MatlabCode) -> SValue MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
mlPrint :: Bool
-> Maybe (SValue MatlabCode)
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
mlPrint Bool
newLn Maybe (SValue MatlabCode)
f' SValue MatlabCode
_ SValue MatlabCode
v' = do
MatlabCode Value
v <- LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Value))
MethodState
ValueState
-> SValue MatlabCode
-> StateT MethodState Identity (MatlabCode Value)
forall c.
LensLike'
(Zoomed (StateT ValueState Identity) c) MethodState ValueState
-> StateT ValueState Identity c -> StateT MethodState Identity c
forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Value))
MethodState
ValueState
(ValueState -> Focusing Identity (MatlabCode Value) ValueState)
-> MethodState -> Focusing Identity (MatlabCode Value) MethodState
Lens' MethodState ValueState
lensMStoVS SValue MatlabCode
v'
Maybe (MatlabCode Value)
mf <- (SValue MatlabCode
-> StateT MethodState Identity (MatlabCode Value))
-> Maybe (SValue MatlabCode)
-> StateT MethodState Identity (Maybe (MatlabCode Value))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse (LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Value))
MethodState
ValueState
-> SValue MatlabCode
-> StateT MethodState Identity (MatlabCode Value)
forall c.
LensLike'
(Zoomed (StateT ValueState Identity) c) MethodState ValueState
-> StateT ValueState Identity c -> StateT MethodState Identity c
forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Value))
MethodState
ValueState
(ValueState -> Focusing Identity (MatlabCode Value) ValueState)
-> MethodState -> Focusing Identity (MatlabCode Value) MethodState
Lens' MethodState ValueState
lensMStoVS) Maybe (SValue MatlabCode)
f'
let fmt :: Label
fmt = case TypeData -> CodeType
cType (Value -> TypeData
valType (MatlabCode Value -> Value
forall a. MatlabCode a -> a
unMLC MatlabCode Value
v)) of
CodeType
String -> Label
"%s"
CodeType
_ -> Label
"%g"
nl :: Label
nl = if Bool
newLn then Label
"\\n" else Label
""
fileArg :: Doc
fileArg = Doc -> (MatlabCode Value -> Doc) -> Maybe (MatlabCode Value) -> Doc
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Doc
empty (\MatlabCode Value
fv -> MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
fv Doc -> Doc -> Doc
<> Doc
listSep') Maybe (MatlabCode Value)
mf
Doc -> Terminator -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
RenderStatement r smt =>
Doc -> Terminator -> MS (r smt)
stmtFromData (Label -> Doc
text Label
"fprintf" Doc -> Doc -> Doc
<>
Doc -> Doc
parens (Doc
fileArg Doc -> Doc -> Doc
<> Label -> Doc
text (Label
"'" Label -> Label -> Label
forall a. [a] -> [a] -> [a]
++ Label
fmt Label -> Label -> Label
forall a. [a] -> [a] -> [a]
++ Label
nl Label -> Label -> Label
forall a. [a] -> [a] -> [a]
++ Label
"'") Doc -> Doc -> Doc
<> Doc
listSep' Doc -> Doc -> Doc
<> MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
v))
Terminator
Semi
mlEnd :: Doc
mlEnd :: Doc
mlEnd = Label -> Doc
text Label
"end"
mlForEach :: (CommonRenderSym r vis smt md) => r Variable ->
r Value -> r Body -> Doc
mlForEach :: forall (r :: * -> *) vis smt md.
CommonRenderSym r vis smt md =>
r Variable -> r Value -> r Doc -> Doc
mlForEach r Variable
i r Value
lstVar r Doc
b = [Doc] -> Doc
vcat [
Label -> Doc
text Label
"for" Doc -> Doc -> Doc
<+> r Variable -> Doc
forall (r :: * -> *). InternalVarElim r => r Variable -> Doc
RC.variable r Variable
i Doc -> Doc -> Doc
<+> Doc
equals Doc -> Doc -> Doc
<+> r Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value r Value
lstVar,
Doc -> Doc
indent (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ r Doc -> Doc
forall (r :: * -> *). BodyElim r => r Doc -> Doc
RC.body r Doc
b,
Doc
mlEnd]
mlRange :: (CommonRenderSym r vis smt md) => SValue r -> SValue r ->
SValue r -> SValue r
mlRange :: forall (r :: * -> *) vis smt md.
CommonRenderSym r vis smt md =>
SValue r -> SValue r -> SValue r -> SValue r
mlRange SValue r
initv SValue r
finalv SValue r
stepv = do
r Value
ini <- SValue r
initv
r Value
fin <- SValue r
finalv
r Value
stp <- SValue r
stepv
r TypeData
d <- VS (r TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
double
r TypeData -> Doc -> SValue r
forall (r :: * -> *).
RenderValue r =>
r TypeData -> Doc -> SValue r
mkVal r TypeData
d (r Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value r Value
ini Doc -> Doc -> Doc
<> Label -> Doc
text Label
":" Doc -> Doc -> Doc
<> r Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value r Value
stp Doc -> Doc -> Doc
<> Label -> Doc
text Label
":" Doc -> Doc -> Doc
<> r Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value r Value
fin)
mlTryCatch :: (CommonRenderSym r vis smt md) => r Body -> r Body -> Doc
mlTryCatch :: forall (r :: * -> *) vis smt md.
CommonRenderSym r vis smt md =>
r Doc -> r Doc -> Doc
mlTryCatch r Doc
tryB r Doc
catchB = [Doc] -> Doc
vcat [
Label -> Doc
text Label
"try",
Doc -> Doc
indent (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ r Doc -> Doc
forall (r :: * -> *). BodyElim r => r Doc -> Doc
RC.body r Doc
tryB,
Label -> Doc
text Label
"catch" Doc -> Doc -> Doc
<+> Label -> Doc
text Label
"e",
Doc -> Doc
indent (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ r Doc -> Doc
forall (r :: * -> *). BodyElim r => r Doc -> Doc
RC.body r Doc
catchB,
Doc
mlEnd]
mlArrayElem :: SValue MatlabCode -> SValue MatlabCode -> SVariable MatlabCode
mlArrayElem :: SValue MatlabCode -> SValue MatlabCode -> SVariable MatlabCode
mlArrayElem SValue MatlabCode
arr' SValue MatlabCode
i' = do
MatlabCode Value
i <- SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *). IndexTranslator r => SValue r -> SValue r
intToIndex SValue MatlabCode
i'
MatlabCode Value
arr <- SValue MatlabCode
arr'
Label -> VS (MatlabCode TypeData) -> Doc -> SVariable MatlabCode
forall (r :: * -> *).
RenderVariable r =>
Label -> VS (r TypeData) -> Doc -> SVariable r
mkStateVar (Doc -> Label
render (Doc -> Label) -> Doc -> Label
forall a b. (a -> b) -> a -> b
$ MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
arr) (VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall (r :: * -> *).
TypeElim r =>
VS (r TypeData) -> VS (r TypeData)
A.innerType (VS (MatlabCode TypeData) -> VS (MatlabCode TypeData))
-> VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall a b. (a -> b) -> a -> b
$ MatlabCode TypeData -> VS (MatlabCode TypeData)
forall a. a -> StateT ValueState Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (MatlabCode TypeData -> VS (MatlabCode TypeData))
-> MatlabCode TypeData -> VS (MatlabCode TypeData)
forall a b. (a -> b) -> a -> b
$ MatlabCode Value -> MatlabCode TypeData
forall (r :: * -> *). ValueSym r => r Value -> r TypeData
valueType MatlabCode Value
arr)
(MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
arr Doc -> Doc -> Doc
<> Doc -> Doc
parens (MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
i))
mlListSet :: SValue MatlabCode -> SValue MatlabCode -> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
mlListSet :: SValue MatlabCode
-> SValue MatlabCode
-> SValue MatlabCode
-> MS (MatlabCode (Doc, Terminator))
mlListSet SValue MatlabCode
lst' SValue MatlabCode
idx' SValue MatlabCode
val' = do
MatlabCode Value
lst <- LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Value))
MethodState
ValueState
-> SValue MatlabCode
-> StateT MethodState Identity (MatlabCode Value)
forall c.
LensLike'
(Zoomed (StateT ValueState Identity) c) MethodState ValueState
-> StateT ValueState Identity c -> StateT MethodState Identity c
forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Value))
MethodState
ValueState
(ValueState -> Focusing Identity (MatlabCode Value) ValueState)
-> MethodState -> Focusing Identity (MatlabCode Value) MethodState
Lens' MethodState ValueState
lensMStoVS SValue MatlabCode
lst'
MatlabCode Value
idx <- LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Value))
MethodState
ValueState
-> SValue MatlabCode
-> StateT MethodState Identity (MatlabCode Value)
forall c.
LensLike'
(Zoomed (StateT ValueState Identity) c) MethodState ValueState
-> StateT ValueState Identity c -> StateT MethodState Identity c
forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom LensLike'
(Zoomed (StateT ValueState Identity) (MatlabCode Value))
MethodState
ValueState
(ValueState -> Focusing Identity (MatlabCode Value) ValueState)
-> MethodState -> Focusing Identity (MatlabCode Value) MethodState
Lens' MethodState ValueState
lensMStoVS (SValue MatlabCode -> SValue MatlabCode
forall (r :: * -> *). IndexTranslator r => SValue r -> SValue r
intToIndex SValue MatlabCode
idx')
let lvar :: SVariable MatlabCode
lvar = Label -> VS (MatlabCode TypeData) -> Doc -> SVariable MatlabCode
forall (r :: * -> *).
RenderVariable r =>
Label -> VS (r TypeData) -> Doc -> SVariable r
mkStateVar (Doc -> Label
render (Doc -> Label) -> Doc -> Label
forall a b. (a -> b) -> a -> b
$ MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
lst)
(VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall (r :: * -> *).
TypeElim r =>
VS (r TypeData) -> VS (r TypeData)
A.innerType (VS (MatlabCode TypeData) -> VS (MatlabCode TypeData))
-> VS (MatlabCode TypeData) -> VS (MatlabCode TypeData)
forall a b. (a -> b) -> a -> b
$ MatlabCode TypeData -> VS (MatlabCode TypeData)
forall a. a -> StateT ValueState Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (MatlabCode TypeData -> VS (MatlabCode TypeData))
-> MatlabCode TypeData -> VS (MatlabCode TypeData)
forall a b. (a -> b) -> a -> b
$ MatlabCode Value -> MatlabCode TypeData
forall (r :: * -> *). ValueSym r => r Value -> r TypeData
valueType MatlabCode Value
lst)
(MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
lst Doc -> Doc -> Doc
<> Doc -> Doc
parens (MatlabCode Value -> Doc
forall (r :: * -> *). ValueElim r => r Value -> Doc
RC.value MatlabCode Value
idx))
SVariable MatlabCode
lvar SVariable MatlabCode
-> SValue MatlabCode -> MS (MatlabCode (Doc, Terminator))
forall (r :: * -> *) smt.
AssignStatement r smt =>
SVariable r -> SValue r -> MS (r smt)
&= SValue MatlabCode
val'