{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PostfixOperators #-}

-- | The logic to render C# code is contained in this module
module Drasil.GOOL.LanguageRenderer.CSharpRenderer (
  -- * C# Code Configuration -- defines syntax of all C# code
  CSharpCode(..), csName, csVersion
) where

import Utils.Drasil (indent)

import Drasil.GOOL.CodeType (CodeType(..))
import Drasil.GOOL.InterfaceCommon (SharedProg, Label, MSBody, VSType,
  VSFunction, SVariable, SValue, MSStatement, MSParameter, SMethod, BodySym(..),
  oneLiner, BlockSym(..), TypeSym(..), TypeElim(..), VariableSym(..),
  VisibilitySym(..), VariableElim(..), ValueSym(..), Argument(..), Literal(..),
  litZero, MathConstant(..), VariableValue(..), CommandLineArgs(..),
  NumericExpression(..), BooleanExpression(..), Comparison(..),
  ValueExpression(..), funcApp, extFuncApp, List(..), Set(..), InternalList(..),
  ThunkSym(..), VectorType(..), VectorDecl(..), VectorThunk(..),
  VectorExpression(..), ThunkAssign(..), StatementSym(..), AssignStatement(..),
  (&=), DeclStatement(..), IOStatement(..), StringStatement(..),
  FunctionSym(..), FuncAppStatement(..), CommentStatement(..),
  ControlStatement(..), ScopeSym(..), ParameterSym(..), MethodSym(..))
import Drasil.GOOL.InterfaceGOOL (OOProg, ProgramSym(..), FileSym(..),
  ModuleSym(..), ClassSym(..), OOTypeSym(..), OOVariableSym(..),
  StateVarSym(..), PermanenceSym(..), OOValueSym, OOVariableValue,
  OOValueExpression(..), selfFuncApp, newObj, InternalValueExp(..),
  objMethodCallNoParams, OOFunctionSym(..), ($.), GetSet(..), OODeclStatement(..),
  OOFuncAppStatement(..), ObserverPattern(..), StrategyPattern(..),
  OOMethodSym(..))
import Drasil.GOOL.RendererClassesCommon (CommonRenderSym, ImportSym(..),
  ImportElim, RenderBody(..), BodyElim, RenderBlock(..),
  BlockElim, RenderType(..), InternalTypeElim, UnaryOpSym(..), BinaryOpSym(..),
  OpElim(uOpPrec, bOpPrec), RenderVariable(..), InternalVarElim(variableBind),
  RenderValue(..), ValueElim(valuePrec, valueInt), InternalListFunc(..),
  RenderFunction(..), FunctionElim(functionType), InternalAssignStmt(..),
  InternalIOStmt(..), InternalControlStmt(..), RenderStatement(..),
  StatementElim(statementTerm), RenderVisibility(..), VisibilityElim, MethodTypeSym(..),
  RenderParam(..), ParamElim(parameterName, parameterType), RenderMethod(..),
  MethodElim, BlockCommentSym(..), BlockCommentElim, ScopeElim(..))
import qualified Drasil.GOOL.RendererClassesCommon as RC (import', body, block,
  type', uOp, bOp, variable, value, function, statement, visibility, parameter,
  method, blockComment')
import Drasil.GOOL.RendererClassesOO (OORenderSym, RenderFile(..),
  PermElim(binding), InternalGetSet(..), OOMethodTypeSym(..),
  OORenderMethod(..), StateVarElim, RenderClass(..), ClassElim, RenderMod(..),
  ModuleElim)
import qualified Drasil.GOOL.RendererClassesOO as RC (perm, stateVar, class',
  module')
import Drasil.GOOL.LanguageRenderer (new, dot, blockCmtStart, blockCmtEnd, 
  docCmtStart, bodyStart, bodyEnd, endStatement, commentStart, elseIfLabel, 
  inLabel, tryLabel, catchLabel, throwLabel, exceptionObj', new', listSep',
  args, nullLabel, listSep, access, containing, mathFunc, valueList, 
  variableList, appendToBody, surroundBody)
import qualified Drasil.GOOL.LanguageRenderer as R (class', multiStmt, body, 
  printFile, param, method, listDec, classVar, func, cast, listSetFunc, 
  castObj, static, dynamic, break, continue, private, public, blockCmt, docCmt, 
  addComments, commentedMod, commentedItem)
import Drasil.GOOL.LanguageRenderer.Constructors (mkStmt,  mkStmtNoEnd,
  mkStateVal, mkVal, VSOp, unOpPrec, powerPrec, unExpr, unExpr', 
  unExprNumDbl, typeUnExpr, binExpr, binExprNumDbl', typeBinExpr)
import qualified Drasil.GOOL.LanguageRenderer.LanguagePolymorphic as G (
  multiBody, block, multiBlock, listInnerType, obj, csc, sec, cot, negateOp,
  equalOp, notEqualOp, greaterOp, greaterEqualOp, lessOp, lessEqualOp, plusOp,
  minusOp, multOp, divideOp, moduloOp, var, staticVar, objVar, arrayElem,
  litChar, litDouble, litInt, litString, valueOf, arg, argsList, objAccess,
  objMethodCall, call, funcAppMixedArgs, selfFuncAppMixedArgs, newObjMixedArgs,
  lambda, func, get, set, listAdd, listAppend, listAccess, listSet, getFunc,
  setFunc, listAppendFunc, stmt, loopStmt, emptyStmt, assign, subAssign,
  increment, objDecNew, print, closeFile, returnStmt, valStmt,
  comment, throw, ifCond, tryCatch, construct, param, method, getMethod,
  setMethod, function, buildClass, implementingClass, commentedClass,
  modFromData, fileDoc, fileFromData, defaultOptSpace, local)
import qualified Drasil.GOOL.LanguageRenderer.CommonPseudoOO as CP (int,
  constructor, doxFunc, doxClass, doxMod, extVar, classVar, objVarSelf,
  extFuncAppMixedArgs, indexOf, contains, listAddFunc, discardFileLine, intClass, 
  arrayType, pi, printSt, arrayDec, arrayDecDef, openFileA, forEach, docMain, 
  mainFunction, buildModule', string, constDecDef, docInOutFunc, bindingError, 
  notNull, listDecDef, destructorError, stateVarDef, constVar, listSetFunc, 
  extraClass, listAccessFunc, doubleRender, openFileR, openFileW, stateVar, 
  inherit, implements, intToIndex, indexToInt, global, setMethodCall)
import qualified Drasil.GOOL.LanguageRenderer.CLike as C (setType, float, double, char, 
  listType, void, notOp, andOp, orOp, self, litTrue, litFalse, litFloat, 
  inlineIf, libFuncAppMixedArgs, libNewObjMixedArgs, listSize, increment1, 
  decrement1, varDec, varDecDef, listDec, extObjDecNew, switch, for, while, 
  intFunc, multiAssignError, multiReturnError, multiTypeError)
import qualified Drasil.GOOL.LanguageRenderer.Macros as M (ifExists, 
  runStrategy, listSlice, stringListVals, stringListLists, forRange, 
  notifyObservers)
import Drasil.GOOL.AST (Terminator(..), FileType(..), FileData(..), fileD, 
  FuncData(..), fd, ModData(..), md, updateMod, MethodData(..), mthd, 
  updateMthd, OpData(..), ParamData(..), pd, updateParam, ProgData(..), progD, 
  TypeData(..), td, ValData(..), vd, updateValDoc, Binding(..), VarData(..), 
  vard, CommonThunk, pureValue, vectorize, vectorize2, sumComponents,
  commonVecIndex, commonThunkElim, commonThunkDim, ScopeData)
import Drasil.GOOL.Helpers (angles, hicat, toCode, toState, onCodeValue, 
  onStateValue, on2CodeValues, on2StateValues, on3CodeValues, on3StateValues, 
  on2StateWrapped, onCodeList, onStateList)
import Drasil.GOOL.State (VS, lensGStoFS, lensMStoVS, modifyReturn, revFiles,
  addLangImport, addLangImportVS, setFileType, getClassName, setCurrMain,
  useVarName, genLoopIndex, setVarScope)

import Prelude hiding (break,print,(<>),sin,cos,tan,floor)
import Control.Lens.Zoom (zoom)
import Control.Monad (join)
import Control.Monad.State (modify)
import Data.Composition ((.:))
import Data.List (intercalate)
import Text.PrettyPrint.HughesPJ (Doc, text, (<>), (<+>), ($$), parens, empty,
  equals, vcat, lbrace, rbrace, braces, colon, space, quotes, semi)

csExt :: String
csExt :: String
csExt = String
"cs"

newtype CSharpCode a = CSC {forall a. CSharpCode a -> a
unCSC :: a} deriving CSharpCode a -> CSharpCode a -> Bool
(CSharpCode a -> CSharpCode a -> Bool)
-> (CSharpCode a -> CSharpCode a -> Bool) -> Eq (CSharpCode a)
forall a. Eq a => CSharpCode a -> CSharpCode a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => CSharpCode a -> CSharpCode a -> Bool
== :: CSharpCode a -> CSharpCode a -> Bool
$c/= :: forall a. Eq a => CSharpCode a -> CSharpCode a -> Bool
/= :: CSharpCode a -> CSharpCode a -> Bool
Eq

instance Functor CSharpCode where
  fmap :: forall a b. (a -> b) -> CSharpCode a -> CSharpCode b
fmap a -> b
f (CSC a
x) = b -> CSharpCode b
forall a. a -> CSharpCode a
CSC (a -> b
f a
x)

instance Applicative CSharpCode where
  pure :: forall a. a -> CSharpCode a
pure = a -> CSharpCode a
forall a. a -> CSharpCode a
CSC
  (CSC a -> b
f) <*> :: forall a b. CSharpCode (a -> b) -> CSharpCode a -> CSharpCode b
<*> (CSC a
x) = b -> CSharpCode b
forall a. a -> CSharpCode a
CSC (a -> b
f a
x)

instance Monad CSharpCode where
  CSC a
x >>= :: forall a b. CSharpCode a -> (a -> CSharpCode b) -> CSharpCode b
>>= a -> CSharpCode b
f = a -> CSharpCode b
f a
x

instance SharedProg CSharpCode
instance OOProg CSharpCode

instance ProgramSym CSharpCode where
  type Program CSharpCode = ProgData
  prog :: String -> String -> [SFile CSharpCode] -> GSProgram CSharpCode
prog String
n String
st [SFile CSharpCode]
files = do
    [CSharpCode FileData]
fs <- (StateT FileState Identity (CSharpCode FileData)
 -> StateT GOOLState Identity (CSharpCode FileData))
-> [StateT FileState Identity (CSharpCode FileData)]
-> StateT GOOLState Identity [CSharpCode FileData]
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) (CSharpCode FileData))
  GOOLState
  FileState
-> StateT FileState Identity (CSharpCode FileData)
-> StateT GOOLState Identity (CSharpCode FileData)
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) (CSharpCode FileData))
  GOOLState
  FileState
(FileState -> Focusing Identity (CSharpCode FileData) FileState)
-> GOOLState -> Focusing Identity (CSharpCode FileData) GOOLState
Lens' GOOLState FileState
lensGStoFS) [StateT FileState Identity (CSharpCode FileData)]
[SFile CSharpCode]
files
    (GOOLState -> GOOLState) -> StateT GOOLState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify GOOLState -> GOOLState
revFiles
    CSharpCode ProgData
-> StateT GOOLState Identity (CSharpCode ProgData)
forall a. a -> StateT GOOLState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CSharpCode ProgData
 -> StateT GOOLState Identity (CSharpCode ProgData))
-> CSharpCode ProgData
-> StateT GOOLState Identity (CSharpCode ProgData)
forall a b. (a -> b) -> a -> b
$ ([FileData] -> ProgData)
-> [CSharpCode FileData] -> CSharpCode ProgData
forall (m :: * -> *) a b. Monad m => ([a] -> b) -> [m a] -> m b
onCodeList (String -> String -> [FileData] -> ProgData
progD String
n String
st) [CSharpCode FileData]
fs

instance CommonRenderSym CSharpCode
instance OORenderSym CSharpCode

instance FileSym CSharpCode where
  type File CSharpCode = FileData
  fileDoc :: FSModule CSharpCode -> SFile CSharpCode
fileDoc FSModule CSharpCode
m = do
    (FileState -> FileState) -> StateT FileState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (FileType -> FileState -> FileState
setFileType FileType
Combined)
    String
-> (CSharpCode (Module CSharpCode)
    -> CSharpCode (Block CSharpCode))
-> CSharpCode (Block CSharpCode)
-> FSModule CSharpCode
-> SFile CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String
-> (r (Module r) -> r (Block r))
-> r (Block r)
-> FSModule r
-> SFile r
G.fileDoc String
csExt CSharpCode (Module CSharpCode) -> CSharpCode (Block CSharpCode)
forall (r :: * -> *). RenderFile r => r (Module r) -> r (Block r)
top CSharpCode (Block CSharpCode)
forall (r :: * -> *). RenderFile r => r (Block r)
bottom FSModule CSharpCode
m

  docMod :: String
-> [String] -> String -> SFile CSharpCode -> SFile CSharpCode
docMod = String
-> String
-> [String]
-> String
-> SFile CSharpCode
-> SFile CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> String -> [String] -> String -> SFile r -> SFile r
CP.doxMod String
csExt

instance RenderFile CSharpCode where
  top :: CSharpCode (Module CSharpCode) -> CSharpCode (Block CSharpCode)
top CSharpCode (Module CSharpCode)
_ = Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
empty
  bottom :: CSharpCode (Block CSharpCode)
bottom = Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
empty

  commentedMod :: SFile CSharpCode
-> FS (CSharpCode (BlockComment CSharpCode)) -> SFile CSharpCode
commentedMod = (CSharpCode FileData -> CSharpCode Doc -> CSharpCode FileData)
-> StateT FileState Identity (CSharpCode FileData)
-> State FileState (CSharpCode Doc)
-> StateT FileState Identity (CSharpCode FileData)
forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues ((FileData -> Doc -> FileData)
-> CSharpCode FileData -> CSharpCode Doc -> CSharpCode FileData
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues FileData -> Doc -> FileData
R.commentedMod)

  fileFromData :: String -> FSModule CSharpCode -> SFile CSharpCode
fileFromData = (String
 -> CSharpCode (Module CSharpCode) -> CSharpCode (File CSharpCode))
-> String -> FSModule CSharpCode -> SFile CSharpCode
forall (r :: * -> *).
OORenderSym r =>
(String -> r (Module r) -> r (File r))
-> String -> FSModule r -> SFile r
G.fileFromData ((ModData -> FileData) -> CSharpCode ModData -> CSharpCode FileData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ((ModData -> FileData)
 -> CSharpCode ModData -> CSharpCode FileData)
-> (String -> ModData -> FileData)
-> String
-> CSharpCode ModData
-> CSharpCode FileData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ModData -> FileData
fileD)

instance ImportSym CSharpCode where
  type Import CSharpCode = Doc
  langImport :: String -> CSharpCode (Import CSharpCode)
langImport = Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode (Doc -> CSharpCode Doc)
-> (String -> Doc) -> String -> CSharpCode Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc
csImport
  modImport :: String -> CSharpCode (Import CSharpCode)
modImport = String -> CSharpCode (Import CSharpCode)
forall (r :: * -> *). ImportSym r => String -> r (Import r)
langImport

instance ImportElim CSharpCode where
  import' :: CSharpCode (Import CSharpCode) -> Doc
import' = CSharpCode Doc -> Doc
CSharpCode (Import CSharpCode) -> Doc
forall a. CSharpCode a -> a
unCSC

instance PermanenceSym CSharpCode where
  type Permanence CSharpCode = Doc
  static :: CSharpCode (Permanence CSharpCode)
static = Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
R.static
  dynamic :: CSharpCode (Permanence CSharpCode)
dynamic = Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
R.dynamic

instance PermElim CSharpCode where
  perm :: CSharpCode (Permanence CSharpCode) -> Doc
perm = CSharpCode Doc -> Doc
CSharpCode (Permanence CSharpCode) -> Doc
forall a. CSharpCode a -> a
unCSC
  binding :: CSharpCode (Permanence CSharpCode) -> Binding
binding = String -> CSharpCode (Permanence CSharpCode) -> Binding
forall a. HasCallStack => String -> a
error (String -> CSharpCode (Permanence CSharpCode) -> Binding)
-> String -> CSharpCode (Permanence CSharpCode) -> Binding
forall a b. (a -> b) -> a -> b
$ String -> String
CP.bindingError String
csName

instance BodySym CSharpCode where
  type Body CSharpCode = Doc
  body :: [MSBlock CSharpCode] -> MSBody CSharpCode
body = ([CSharpCode Doc] -> CSharpCode Doc)
-> [State MethodState (CSharpCode Doc)]
-> State MethodState (CSharpCode Doc)
forall a b s. ([a] -> b) -> [State s a] -> State s b
onStateList (([Doc] -> Doc) -> [CSharpCode Doc] -> CSharpCode Doc
forall (m :: * -> *) a b. Monad m => ([a] -> b) -> [m a] -> m b
onCodeList [Doc] -> Doc
R.body)

  addComments :: String -> MSBody CSharpCode -> MSBody CSharpCode
addComments String
s = (CSharpCode Doc -> CSharpCode Doc)
-> State MethodState (CSharpCode Doc)
-> State MethodState (CSharpCode Doc)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue ((Doc -> Doc) -> CSharpCode Doc -> CSharpCode Doc
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue (String -> Doc -> Doc -> Doc
R.addComments String
s Doc
commentStart))

instance RenderBody CSharpCode where
  multiBody :: [MSBody CSharpCode] -> MSBody CSharpCode
multiBody = [MSBody CSharpCode] -> State MethodState (CSharpCode Doc)
[MSBody CSharpCode] -> MSBody CSharpCode
forall (r :: * -> *).
(CommonRenderSym r, Monad r) =>
[MSBody r] -> MS (r Doc)
G.multiBody 

instance BodyElim CSharpCode where
  body :: CSharpCode (Body CSharpCode) -> Doc
body = CSharpCode Doc -> Doc
CSharpCode (Body CSharpCode) -> Doc
forall a. CSharpCode a -> a
unCSC

instance BlockSym CSharpCode where
  type Block CSharpCode = Doc
  block :: [MSStatement CSharpCode] -> MSBlock CSharpCode
block = [MSStatement CSharpCode] -> State MethodState (CSharpCode Doc)
[MSStatement CSharpCode] -> MSBlock CSharpCode
forall (r :: * -> *).
(CommonRenderSym r, Monad r) =>
[MSStatement r] -> MS (r Doc)
G.block

instance RenderBlock CSharpCode where
  multiBlock :: [MSBlock CSharpCode] -> MSBlock CSharpCode
multiBlock = [MSBlock CSharpCode] -> State MethodState (CSharpCode Doc)
[MSBlock CSharpCode] -> MSBlock CSharpCode
forall (r :: * -> *).
(CommonRenderSym r, Monad r) =>
[MSBlock r] -> MS (r Doc)
G.multiBlock

instance BlockElim CSharpCode where
  block :: CSharpCode (Block CSharpCode) -> Doc
block = CSharpCode Doc -> Doc
CSharpCode (Block CSharpCode) -> Doc
forall a. CSharpCode a -> a
unCSC

instance TypeSym CSharpCode where
  type Type CSharpCode = TypeData
  bool :: VSType CSharpCode
bool = VS (CSharpCode TypeData) -> VS (CSharpCode TypeData)
forall a. VS a -> VS a
addSystemImport VS (CSharpCode TypeData)
VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => VSType r
csBoolType
  int :: VSType CSharpCode
int = VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => VSType r
CP.int
  float :: VSType CSharpCode
float = VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => VSType r
C.float
  double :: VSType CSharpCode
double = VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => VSType r
C.double
  char :: VSType CSharpCode
char = VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => VSType r
C.char
  string :: VSType CSharpCode
string = VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => VSType r
CP.string
  infile :: VSType CSharpCode
infile = VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => VSType r
csInfileType
  outfile :: VSType CSharpCode
outfile = VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => VSType r
csOutfileType
  listType :: VSType CSharpCode -> VSType CSharpCode
listType VSType CSharpCode
t = do
    (ValueState -> ValueState) -> StateT ValueState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (String -> ValueState -> ValueState
addLangImportVS String
csGeneric) 
    String -> VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
String -> VSType r -> VSType r
C.listType String
csList VSType CSharpCode
t
  arrayType :: VSType CSharpCode -> VSType CSharpCode
arrayType = VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => VSType r -> VSType r
CP.arrayType
  setType :: VSType CSharpCode -> VSType CSharpCode
setType VSType CSharpCode
t = do
    (ValueState -> ValueState) -> StateT ValueState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (String -> ValueState -> ValueState
addLangImportVS String
csGeneric) 
    String -> VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> VSType r -> VSType r
C.setType String
csSet VSType CSharpCode
t
  listInnerType :: VSType CSharpCode -> VSType CSharpCode
listInnerType = VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *). OORenderSym r => VSType r -> VSType r
G.listInnerType
  funcType :: [VSType CSharpCode] -> VSType CSharpCode -> VSType CSharpCode
funcType = [VSType CSharpCode] -> VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
[VSType r] -> VSType r -> VSType r
csFuncType
  void :: VSType CSharpCode
void = VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => VSType r
C.void

instance OOTypeSym CSharpCode where
  obj :: String -> VSType CSharpCode
obj = String -> VSType CSharpCode
forall (r :: * -> *). CommonRenderSym r => String -> VSType r
G.obj

instance TypeElim CSharpCode where
  getType :: CSharpCode (Type CSharpCode) -> CodeType
getType = TypeData -> CodeType
cType (TypeData -> CodeType)
-> (CSharpCode TypeData -> TypeData)
-> CSharpCode TypeData
-> CodeType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode TypeData -> TypeData
forall a. CSharpCode a -> a
unCSC
  getTypeString :: CSharpCode (Type CSharpCode) -> String
getTypeString = TypeData -> String
typeString (TypeData -> String)
-> (CSharpCode TypeData -> TypeData)
-> CSharpCode TypeData
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode TypeData -> TypeData
forall a. CSharpCode a -> a
unCSC
  
instance RenderType CSharpCode where
  multiType :: [VSType CSharpCode] -> VSType CSharpCode
multiType [VSType CSharpCode]
_ = String -> VSType CSharpCode
forall a. HasCallStack => String -> a
error (String -> VSType CSharpCode) -> String -> VSType CSharpCode
forall a b. (a -> b) -> a -> b
$ String -> String
C.multiTypeError String
csName
  typeFromData :: CodeType -> String -> Doc -> VSType CSharpCode
typeFromData CodeType
t String
s Doc
d = CSharpCode (Type CSharpCode) -> VSType CSharpCode
forall a s. a -> State s a
toState (CSharpCode (Type CSharpCode) -> VSType CSharpCode)
-> CSharpCode (Type CSharpCode) -> VSType CSharpCode
forall a b. (a -> b) -> a -> b
$ TypeData -> CSharpCode TypeData
forall (r :: * -> *) a. Monad r => a -> r a
toCode (TypeData -> CSharpCode TypeData)
-> TypeData -> CSharpCode TypeData
forall a b. (a -> b) -> a -> b
$ CodeType -> String -> Doc -> TypeData
td CodeType
t String
s Doc
d

instance InternalTypeElim CSharpCode where
  type' :: CSharpCode (Type CSharpCode) -> Doc
type' = TypeData -> Doc
typeDoc (TypeData -> Doc)
-> (CSharpCode TypeData -> TypeData) -> CSharpCode TypeData -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode TypeData -> TypeData
forall a. CSharpCode a -> a
unCSC

instance UnaryOpSym CSharpCode where
  type UnaryOp CSharpCode = OpData
  notOp :: VSUnOp CSharpCode
notOp = VSOp CSharpCode
VSUnOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
C.notOp
  negateOp :: VSUnOp CSharpCode
negateOp = VSOp CSharpCode
VSUnOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.negateOp
  sqrtOp :: VSUnOp CSharpCode
sqrtOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Sqrt"
  absOp :: VSUnOp CSharpCode
absOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Abs"
  logOp :: VSUnOp CSharpCode
logOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Log10"
  lnOp :: VSUnOp CSharpCode
lnOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Log"
  expOp :: VSUnOp CSharpCode
expOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Exp"
  sinOp :: VSUnOp CSharpCode
sinOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Sin"
  cosOp :: VSUnOp CSharpCode
cosOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Cos"
  tanOp :: VSUnOp CSharpCode
tanOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Tan"
  asinOp :: VSUnOp CSharpCode
asinOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Asin"
  acosOp :: VSUnOp CSharpCode
acosOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Acos"
  atanOp :: VSUnOp CSharpCode
atanOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Atan"
  floorOp :: VSUnOp CSharpCode
floorOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Floor"
  ceilOp :: VSUnOp CSharpCode
ceilOp = String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath String
"Ceiling"

instance BinaryOpSym CSharpCode where
  type BinaryOp CSharpCode = OpData
  equalOp :: VSBinOp CSharpCode
equalOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.equalOp
  notEqualOp :: VSBinOp CSharpCode
notEqualOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.notEqualOp
  greaterOp :: VSBinOp CSharpCode
greaterOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.greaterOp
  greaterEqualOp :: VSBinOp CSharpCode
greaterEqualOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.greaterEqualOp
  lessOp :: VSBinOp CSharpCode
lessOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.lessOp
  lessEqualOp :: VSBinOp CSharpCode
lessEqualOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.lessEqualOp
  plusOp :: VSBinOp CSharpCode
plusOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.plusOp
  minusOp :: VSBinOp CSharpCode
minusOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.minusOp
  multOp :: VSBinOp CSharpCode
multOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.multOp
  divideOp :: VSBinOp CSharpCode
divideOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.divideOp
  powerOp :: VSBinOp CSharpCode
powerOp = VSBinOp CSharpCode -> VSBinOp CSharpCode
forall a. VS a -> VS a
addSystemImport (VSBinOp CSharpCode -> VSBinOp CSharpCode)
-> VSBinOp CSharpCode -> VSBinOp CSharpCode
forall a b. (a -> b) -> a -> b
$ String -> VSOp CSharpCode
forall (r :: * -> *). Monad r => String -> VSOp r
powerPrec (String -> VSOp CSharpCode) -> String -> VSOp CSharpCode
forall a b. (a -> b) -> a -> b
$ String -> String
mathFunc String
"Pow"
  moduloOp :: VSBinOp CSharpCode
moduloOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
G.moduloOp
  andOp :: VSBinOp CSharpCode
andOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
C.andOp
  orOp :: VSBinOp CSharpCode
orOp = VSOp CSharpCode
VSBinOp CSharpCode
forall (r :: * -> *). Monad r => VSOp r
C.orOp

instance OpElim CSharpCode where
  uOp :: CSharpCode (UnaryOp CSharpCode) -> Doc
uOp = OpData -> Doc
opDoc (OpData -> Doc)
-> (CSharpCode OpData -> OpData) -> CSharpCode OpData -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode OpData -> OpData
forall a. CSharpCode a -> a
unCSC
  bOp :: CSharpCode (BinaryOp CSharpCode) -> Doc
bOp = OpData -> Doc
opDoc (OpData -> Doc)
-> (CSharpCode OpData -> OpData) -> CSharpCode OpData -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode OpData -> OpData
forall a. CSharpCode a -> a
unCSC
  uOpPrec :: CSharpCode (UnaryOp CSharpCode) -> Int
uOpPrec = OpData -> Int
opPrec (OpData -> Int)
-> (CSharpCode OpData -> OpData) -> CSharpCode OpData -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode OpData -> OpData
forall a. CSharpCode a -> a
unCSC
  bOpPrec :: CSharpCode (BinaryOp CSharpCode) -> Int
bOpPrec = OpData -> Int
opPrec (OpData -> Int)
-> (CSharpCode OpData -> OpData) -> CSharpCode OpData -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode OpData -> OpData
forall a. CSharpCode a -> a
unCSC

instance ScopeSym CSharpCode where
  type Scope CSharpCode = ScopeData
  global :: CSharpCode (Scope CSharpCode)
global = CSharpCode ScopeData
CSharpCode (Scope CSharpCode)
forall (r :: * -> *). Monad r => r ScopeData
CP.global
  mainFn :: CSharpCode (Scope CSharpCode)
mainFn = CSharpCode (Scope CSharpCode)
forall (r :: * -> *). ScopeSym r => r (Scope r)
local
  local :: CSharpCode (Scope CSharpCode)
local = CSharpCode ScopeData
CSharpCode (Scope CSharpCode)
forall (r :: * -> *). Monad r => r ScopeData
G.local

instance ScopeElim CSharpCode where
  scopeData :: CSharpCode (Scope CSharpCode) -> ScopeData
scopeData = CSharpCode ScopeData -> ScopeData
CSharpCode (Scope CSharpCode) -> ScopeData
forall a. CSharpCode a -> a
unCSC

instance VariableSym CSharpCode where
  type Variable CSharpCode = VarData
  var :: String -> VSType CSharpCode -> SVariable CSharpCode
var         = String -> VSType CSharpCode -> SVariable CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
String -> VSType r -> SVariable r
G.var
  constant :: String -> VSType CSharpCode -> SVariable CSharpCode
constant    = String -> VSType CSharpCode -> SVariable CSharpCode
forall (r :: * -> *).
VariableSym r =>
String -> VSType r -> SVariable r
var
  extVar :: String -> String -> VSType CSharpCode -> SVariable CSharpCode
extVar      = String -> String -> VSType CSharpCode -> SVariable CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
String -> String -> VSType r -> SVariable r
CP.extVar
  arrayElem :: Integer -> SVariable CSharpCode -> SVariable CSharpCode
arrayElem Integer
i = SValue CSharpCode -> SVariable CSharpCode -> SVariable CSharpCode
forall (r :: * -> *).
OORenderSym r =>
SValue r -> SVariable r -> SVariable r
G.arrayElem (Integer -> SValue CSharpCode
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
i)

instance OOVariableSym CSharpCode where
  staticVar' :: Bool -> String -> VSType CSharpCode -> SVariable CSharpCode
staticVar' Bool
_ = String -> VSType CSharpCode -> SVariable CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
String -> VSType r -> SVariable r
G.staticVar
  self :: SVariable CSharpCode
self = SVariable CSharpCode
forall (r :: * -> *). OORenderSym r => SVariable r
C.self
  classVar :: VSType CSharpCode -> SVariable CSharpCode -> SVariable CSharpCode
classVar = (Doc -> Doc -> Doc)
-> VSType CSharpCode
-> SVariable CSharpCode
-> SVariable CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(Doc -> Doc -> Doc) -> VSType r -> SVariable r -> SVariable r
CP.classVar Doc -> Doc -> Doc
R.classVar
  extClassVar :: VSType CSharpCode -> SVariable CSharpCode -> SVariable CSharpCode
extClassVar = VSType CSharpCode -> SVariable CSharpCode -> SVariable CSharpCode
forall (r :: * -> *).
OOVariableSym r =>
VSType r -> SVariable r -> SVariable r
classVar
  objVar :: SVariable CSharpCode
-> SVariable CSharpCode -> SVariable CSharpCode
objVar = SVariable CSharpCode
-> SVariable CSharpCode -> SVariable CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SVariable r -> SVariable r -> SVariable r
G.objVar
  objVarSelf :: SVariable CSharpCode -> SVariable CSharpCode
objVarSelf = SVariable CSharpCode -> SVariable CSharpCode
forall (r :: * -> *). OORenderSym r => SVariable r -> SVariable r
CP.objVarSelf

instance VariableElim CSharpCode where
  variableName :: CSharpCode (Variable CSharpCode) -> String
variableName = VarData -> String
varName (VarData -> String)
-> (CSharpCode VarData -> VarData) -> CSharpCode VarData -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode VarData -> VarData
forall a. CSharpCode a -> a
unCSC
  variableType :: CSharpCode (Variable CSharpCode) -> CSharpCode (Type CSharpCode)
variableType = (VarData -> TypeData) -> CSharpCode VarData -> CSharpCode TypeData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue VarData -> TypeData
varType

instance InternalVarElim CSharpCode where
  variableBind :: CSharpCode (Variable CSharpCode) -> Binding
variableBind = VarData -> Binding
varBind (VarData -> Binding)
-> (CSharpCode VarData -> VarData) -> CSharpCode VarData -> Binding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode VarData -> VarData
forall a. CSharpCode a -> a
unCSC
  variable :: CSharpCode (Variable CSharpCode) -> Doc
variable = VarData -> Doc
varDoc (VarData -> Doc)
-> (CSharpCode VarData -> VarData) -> CSharpCode VarData -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode VarData -> VarData
forall a. CSharpCode a -> a
unCSC

instance RenderVariable CSharpCode where
  varFromData :: Binding
-> String -> VSType CSharpCode -> Doc -> SVariable CSharpCode
varFromData Binding
b String
n VSType CSharpCode
t' Doc
d = do 
    CSharpCode TypeData
t <- VS (CSharpCode TypeData)
VSType CSharpCode
t'
    CSharpCode VarData -> State ValueState (CSharpCode VarData)
forall a s. a -> State s a
toState (CSharpCode VarData -> State ValueState (CSharpCode VarData))
-> CSharpCode VarData -> State ValueState (CSharpCode VarData)
forall a b. (a -> b) -> a -> b
$ (TypeData -> Doc -> VarData)
-> CSharpCode TypeData -> CSharpCode Doc -> CSharpCode VarData
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues (Binding -> String -> TypeData -> Doc -> VarData
vard Binding
b String
n) CSharpCode TypeData
t (Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
d)

instance ValueSym CSharpCode where
  type Value CSharpCode = ValData
  valueType :: CSharpCode (Value CSharpCode) -> CSharpCode (Type CSharpCode)
valueType = (ValData -> TypeData) -> CSharpCode ValData -> CSharpCode TypeData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ValData -> TypeData
valType

instance OOValueSym CSharpCode

instance Argument CSharpCode where
  pointerArg :: SValue CSharpCode -> SValue CSharpCode
pointerArg = VS (CSharpCode ValData) -> VS (CSharpCode ValData)
SValue CSharpCode -> SValue CSharpCode
forall a. a -> a
id

instance Literal CSharpCode where
  litTrue :: SValue CSharpCode
litTrue = SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => SValue r
C.litTrue
  litFalse :: SValue CSharpCode
litFalse = SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => SValue r
C.litFalse
  litChar :: Char -> SValue CSharpCode
litChar = (Doc -> Doc) -> Char -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(Doc -> Doc) -> Char -> SValue r
G.litChar Doc -> Doc
quotes
  litDouble :: Double -> SValue CSharpCode
litDouble = Double -> SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => Double -> SValue r
G.litDouble
  litFloat :: Float -> SValue CSharpCode
litFloat = Float -> SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => Float -> SValue r
C.litFloat
  litInt :: Integer -> SValue CSharpCode
litInt = Integer -> SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => Integer -> SValue r
G.litInt
  litString :: String -> SValue CSharpCode
litString = String -> SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => String -> SValue r
G.litString
  litArray :: VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
litArray = (VSType CSharpCode -> VSType CSharpCode)
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(VSType r -> VSType r) -> VSType r -> [SValue r] -> SValue r
csLitList VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r -> VSType r
arrayType
  litSet :: VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
litSet = (VSType CSharpCode -> VSType CSharpCode)
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(VSType r -> VSType r) -> VSType r -> [SValue r] -> SValue r
csLitList VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r -> VSType r
setType
  litList :: VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
litList = (VSType CSharpCode -> VSType CSharpCode)
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(VSType r -> VSType r) -> VSType r -> [SValue r] -> SValue r
csLitList VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r -> VSType r
listType

instance MathConstant CSharpCode where
  pi :: SValue CSharpCode
pi = SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => SValue r
CP.pi

instance VariableValue CSharpCode where
  valueOf :: SVariable CSharpCode -> SValue CSharpCode
valueOf = SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => SVariable r -> SValue r
G.valueOf

instance OOVariableValue CSharpCode

instance CommandLineArgs CSharpCode where
  arg :: Integer -> SValue CSharpCode
arg Integer
n = SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SValue r -> SValue r -> SValue r
G.arg (Integer -> SValue CSharpCode
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
n) SValue CSharpCode
forall (r :: * -> *). CommandLineArgs r => SValue r
argsList
  argsList :: SValue CSharpCode
argsList = String -> SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => String -> SValue r
G.argsList String
args
  argExists :: Integer -> SValue CSharpCode
argExists Integer
i = SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). List r => SValue r -> SValue r
listSize SValue CSharpCode
forall (r :: * -> *). CommandLineArgs r => SValue r
argsList SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
Comparison r =>
SValue r -> SValue r -> SValue r
?> Integer -> SValue CSharpCode
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt (Integer -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
i)

instance NumericExpression CSharpCode where
  #~ :: SValue CSharpCode -> SValue CSharpCode
(#~) = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExpr' VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
negateOp
  #/^ :: SValue CSharpCode -> SValue CSharpCode
(#/^) = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
sqrtOp
  #| :: SValue CSharpCode -> SValue CSharpCode
(#|) = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
absOp
  #+ :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(#+) = VSBinOp CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
plusOp
  #- :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(#-) = VSBinOp CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
minusOp
  #* :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(#*) = VSBinOp CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
multOp
  #/ :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(#/) = VSBinOp CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
divideOp
  #% :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(#%) = VSBinOp CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
moduloOp
  #^ :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(#^) = VSBinOp CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExprNumDbl' VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
powerOp

  log :: SValue CSharpCode -> SValue CSharpCode
log = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
logOp
  ln :: SValue CSharpCode -> SValue CSharpCode
ln = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
lnOp
  exp :: SValue CSharpCode -> SValue CSharpCode
exp = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
expOp
  sin :: SValue CSharpCode -> SValue CSharpCode
sin = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
sinOp
  cos :: SValue CSharpCode -> SValue CSharpCode
cos = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
cosOp
  tan :: SValue CSharpCode -> SValue CSharpCode
tan = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
tanOp
  csc :: SValue CSharpCode -> SValue CSharpCode
csc = SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => SValue r -> SValue r
G.csc
  sec :: SValue CSharpCode -> SValue CSharpCode
sec = SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => SValue r -> SValue r
G.sec
  cot :: SValue CSharpCode -> SValue CSharpCode
cot = SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). CommonRenderSym r => SValue r -> SValue r
G.cot
  arcsin :: SValue CSharpCode -> SValue CSharpCode
arcsin = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
asinOp
  arccos :: SValue CSharpCode -> SValue CSharpCode
arccos = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
acosOp
  arctan :: SValue CSharpCode -> SValue CSharpCode
arctan = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
atanOp
  floor :: SValue CSharpCode -> SValue CSharpCode
floor = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
floorOp
  ceil :: SValue CSharpCode -> SValue CSharpCode
ceil = VSUnOp CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExpr VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
ceilOp

instance BooleanExpression CSharpCode where
  ?! :: SValue CSharpCode -> SValue CSharpCode
(?!) = VSUnOp CSharpCode
-> VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSUnOp r -> VSType r -> SValue r -> SValue r
typeUnExpr VSUnOp CSharpCode
forall (r :: * -> *). UnaryOpSym r => VSUnOp r
notOp VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool
  ?&& :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(?&&) = VSBinOp CSharpCode
-> VSType CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
andOp VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool
  ?|| :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(?||) = VSBinOp CSharpCode
-> VSType CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
orOp VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool

instance Comparison CSharpCode where
  ?< :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(?<) = VSBinOp CSharpCode
-> VSType CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
lessOp VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool
  ?<= :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(?<=) = VSBinOp CSharpCode
-> VSType CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
lessEqualOp VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool
  ?> :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(?>) = VSBinOp CSharpCode
-> VSType CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
greaterOp VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool
  ?>= :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(?>=) = VSBinOp CSharpCode
-> VSType CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
greaterEqualOp VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool
  ?== :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(?==) = VSBinOp CSharpCode
-> VSType CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
equalOp VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool
  ?!= :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
(?!=) = VSBinOp CSharpCode
-> VSType CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr VSBinOp CSharpCode
forall (r :: * -> *). BinaryOpSym r => VSBinOp r
notEqualOp VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool

instance ValueExpression CSharpCode where
  inlineIf :: SValue CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
inlineIf = SValue CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SValue r -> SValue r -> SValue r -> SValue r
C.inlineIf

  funcAppMixedArgs :: MixedCall CSharpCode
funcAppMixedArgs = MixedCall CSharpCode
forall (r :: * -> *). CommonRenderSym r => MixedCall r
G.funcAppMixedArgs
  extFuncAppMixedArgs :: String -> MixedCall CSharpCode
extFuncAppMixedArgs = String -> MixedCall CSharpCode
forall (r :: * -> *). CommonRenderSym r => String -> MixedCall r
CP.extFuncAppMixedArgs
  libFuncAppMixedArgs :: String -> MixedCall CSharpCode
libFuncAppMixedArgs = String -> MixedCall CSharpCode
forall (r :: * -> *). CommonRenderSym r => String -> MixedCall r
C.libFuncAppMixedArgs

  lambda :: [SVariable CSharpCode] -> SValue CSharpCode -> SValue CSharpCode
lambda = ([CSharpCode (Variable CSharpCode)]
 -> CSharpCode (Value CSharpCode) -> Doc)
-> [SVariable CSharpCode] -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
([r (Variable r)] -> r (Value r) -> Doc)
-> [SVariable r] -> SValue r -> SValue r
G.lambda [CSharpCode (Variable CSharpCode)]
-> CSharpCode (Value CSharpCode) -> Doc
forall (r :: * -> *).
CommonRenderSym r =>
[r (Variable r)] -> r (Value r) -> Doc
csLambda

  notNull :: SValue CSharpCode -> SValue CSharpCode
notNull = String -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
String -> SValue r -> SValue r
CP.notNull String
nullLabel

instance OOValueExpression CSharpCode where
  selfFuncAppMixedArgs :: MixedCall CSharpCode
selfFuncAppMixedArgs = Doc -> SVariable CSharpCode -> MixedCall CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Doc -> SVariable r -> MixedCall r
G.selfFuncAppMixedArgs Doc
dot SVariable CSharpCode
forall (r :: * -> *). OOVariableSym r => SVariable r
self
  newObjMixedArgs :: MixedCtorCall CSharpCode
newObjMixedArgs = MixedCall CSharpCode
forall (r :: * -> *). CommonRenderSym r => MixedCall r
G.newObjMixedArgs (String
new String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" ")
  extNewObjMixedArgs :: MixedCall CSharpCode
extNewObjMixedArgs String
_ = MixedCtorCall CSharpCode
forall (r :: * -> *). OOValueExpression r => MixedCtorCall r
newObjMixedArgs
  libNewObjMixedArgs :: MixedCall CSharpCode
libNewObjMixedArgs = MixedCall CSharpCode
forall (r :: * -> *). OORenderSym r => String -> MixedCtorCall r
C.libNewObjMixedArgs

instance RenderValue CSharpCode where
  inputFunc :: SValue CSharpCode
inputFunc = VS (CSharpCode ValData) -> VS (CSharpCode ValData)
forall a. VS a -> VS a
addSystemImport VS (CSharpCode ValData)
SValue CSharpCode
csReadLineFunc
  printFunc :: SValue CSharpCode
printFunc = SValue CSharpCode -> SValue CSharpCode
forall a. VS a -> VS a
addSystemImport (SValue CSharpCode -> SValue CSharpCode)
-> SValue CSharpCode -> SValue CSharpCode
forall a b. (a -> b) -> a -> b
$ VSType CSharpCode -> Doc -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSType r -> Doc -> SValue r
mkStateVal VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
void (String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ String
csConsole String -> String -> String
`access` 
    String
csWrite)
  printLnFunc :: SValue CSharpCode
printLnFunc = SValue CSharpCode -> SValue CSharpCode
forall a. VS a -> VS a
addSystemImport (SValue CSharpCode -> SValue CSharpCode)
-> SValue CSharpCode -> SValue CSharpCode
forall a b. (a -> b) -> a -> b
$ VSType CSharpCode -> Doc -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSType r -> Doc -> SValue r
mkStateVal VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
void (String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ String
csConsole String -> String -> String
`access` 
    String
csWriteLine)
  printFileFunc :: SValue CSharpCode -> SValue CSharpCode
printFileFunc SValue CSharpCode
w' = (CSharpCode (Value CSharpCode)
 -> CSharpCode TypeData -> VS (CSharpCode ValData))
-> SValue CSharpCode
-> VS (CSharpCode TypeData)
-> VS (CSharpCode ValData)
forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> m a -> m b -> m c
on2StateWrapped (\CSharpCode (Value CSharpCode)
w CSharpCode TypeData
vt -> 
    CSharpCode (Type CSharpCode) -> Doc -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
r (Type r) -> Doc -> SValue r
mkVal CSharpCode TypeData
CSharpCode (Type CSharpCode)
vt (Doc -> VS (CSharpCode ValData))
-> (CSharpCode (Value CSharpCode) -> Doc)
-> CSharpCode (Value CSharpCode)
-> VS (CSharpCode ValData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc -> Doc
R.printFile String
csWrite (Doc -> Doc)
-> (CSharpCode (Value CSharpCode) -> Doc)
-> CSharpCode (Value CSharpCode)
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode (Value CSharpCode) -> Doc
forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value (CSharpCode (Value CSharpCode) -> VS (CSharpCode ValData))
-> CSharpCode (Value CSharpCode) -> VS (CSharpCode ValData)
forall a b. (a -> b) -> a -> b
$ CSharpCode (Value CSharpCode)
w) SValue CSharpCode
w' VS (CSharpCode TypeData)
VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
void
  printFileLnFunc :: SValue CSharpCode -> SValue CSharpCode
printFileLnFunc SValue CSharpCode
w' = (CSharpCode (Value CSharpCode)
 -> CSharpCode TypeData -> VS (CSharpCode ValData))
-> SValue CSharpCode
-> VS (CSharpCode TypeData)
-> VS (CSharpCode ValData)
forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> m a -> m b -> m c
on2StateWrapped (\CSharpCode (Value CSharpCode)
w CSharpCode TypeData
vt -> 
    CSharpCode (Type CSharpCode) -> Doc -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
r (Type r) -> Doc -> SValue r
mkVal CSharpCode TypeData
CSharpCode (Type CSharpCode)
vt (Doc -> VS (CSharpCode ValData))
-> (CSharpCode (Value CSharpCode) -> Doc)
-> CSharpCode (Value CSharpCode)
-> VS (CSharpCode ValData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc -> Doc
R.printFile String
csWriteLine (Doc -> Doc)
-> (CSharpCode (Value CSharpCode) -> Doc)
-> CSharpCode (Value CSharpCode)
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode (Value CSharpCode) -> Doc
forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value (CSharpCode (Value CSharpCode) -> VS (CSharpCode ValData))
-> CSharpCode (Value CSharpCode) -> VS (CSharpCode ValData)
forall a b. (a -> b) -> a -> b
$ CSharpCode (Value CSharpCode)
w) SValue CSharpCode
w' VS (CSharpCode TypeData)
VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
void
  
  cast :: VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
cast = VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
csCast

  call :: Maybe String -> Maybe Doc -> MixedCall CSharpCode
call = Doc -> Maybe String -> Maybe Doc -> MixedCall CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Doc -> Maybe String -> Maybe Doc -> MixedCall r
G.call Doc
csNamedArgSep
  
  valFromData :: Maybe Int
-> Maybe Integer -> VSType CSharpCode -> Doc -> SValue CSharpCode
valFromData Maybe Int
p Maybe Integer
i VSType CSharpCode
t' Doc
d = do 
    CSharpCode TypeData
t <- VS (CSharpCode TypeData)
VSType CSharpCode
t' 
    CSharpCode ValData -> VS (CSharpCode ValData)
forall a s. a -> State s a
toState (CSharpCode ValData -> VS (CSharpCode ValData))
-> CSharpCode ValData -> VS (CSharpCode ValData)
forall a b. (a -> b) -> a -> b
$ (TypeData -> Doc -> ValData)
-> CSharpCode TypeData -> CSharpCode Doc -> CSharpCode ValData
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues (Maybe Int -> Maybe Integer -> TypeData -> Doc -> ValData
vd Maybe Int
p Maybe Integer
i) CSharpCode TypeData
t (Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
d)
  
instance ValueElim CSharpCode where
  valuePrec :: CSharpCode (Value CSharpCode) -> Maybe Int
valuePrec = ValData -> Maybe Int
valPrec (ValData -> Maybe Int)
-> (CSharpCode ValData -> ValData)
-> CSharpCode ValData
-> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode ValData -> ValData
forall a. CSharpCode a -> a
unCSC
  valueInt :: CSharpCode (Value CSharpCode) -> Maybe Integer
valueInt = ValData -> Maybe Integer
valInt (ValData -> Maybe Integer)
-> (CSharpCode ValData -> ValData)
-> CSharpCode ValData
-> Maybe Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode ValData -> ValData
forall a. CSharpCode a -> a
unCSC
  value :: CSharpCode (Value CSharpCode) -> Doc
value = ValData -> Doc
val (ValData -> Doc)
-> (CSharpCode ValData -> ValData) -> CSharpCode ValData -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode ValData -> ValData
forall a. CSharpCode a -> a
unCSC
  
instance InternalValueExp CSharpCode where
  objMethodCallMixedArgs' :: String
-> VSType CSharpCode
-> SValue CSharpCode
-> [SValue CSharpCode]
-> NamedArgs CSharpCode
-> SValue CSharpCode
objMethodCallMixedArgs' = String
-> VSType CSharpCode
-> SValue CSharpCode
-> [SValue CSharpCode]
-> NamedArgs CSharpCode
-> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
String
-> VSType r -> SValue r -> [SValue r] -> NamedArgs r -> SValue r
G.objMethodCall

instance FunctionSym CSharpCode where
  type Function CSharpCode = FuncData

instance OOFunctionSym CSharpCode where
  func :: String
-> VSType CSharpCode
-> [SValue CSharpCode]
-> VSFunction CSharpCode
func = String
-> VSType CSharpCode
-> [SValue CSharpCode]
-> VSFunction CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
G.func
  objAccess :: SValue CSharpCode -> VSFunction CSharpCode -> SValue CSharpCode
objAccess = SValue CSharpCode -> VSFunction CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SValue r -> VSFunction r -> SValue r
G.objAccess

instance GetSet CSharpCode where
  get :: SValue CSharpCode -> SVariable CSharpCode -> SValue CSharpCode
get = SValue CSharpCode -> SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
SValue r -> SVariable r -> SValue r
G.get
  set :: SValue CSharpCode
-> SVariable CSharpCode -> SValue CSharpCode -> SValue CSharpCode
set = SValue CSharpCode
-> SVariable CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
SValue r -> SVariable r -> SValue r -> SValue r
G.set

instance List CSharpCode where
  intToIndex :: SValue CSharpCode -> SValue CSharpCode
intToIndex = SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). SValue r -> SValue r
CP.intToIndex
  indexToInt :: SValue CSharpCode -> SValue CSharpCode
indexToInt = SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). SValue r -> SValue r
CP.indexToInt
  listSize :: SValue CSharpCode -> SValue CSharpCode
listSize = SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). OORenderSym r => SValue r -> SValue r
C.listSize
  listAdd :: SValue CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
listAdd = SValue CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
SValue r -> SValue r -> SValue r -> SValue r
G.listAdd
  listAppend :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
listAppend = SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
SValue r -> SValue r -> SValue r
G.listAppend
  listAccess :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
listAccess = SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SValue r -> SValue r -> SValue r
G.listAccess
  listSet :: SValue CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
listSet = SValue CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SValue r -> SValue r -> SValue r -> SValue r
G.listSet
  indexOf :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
indexOf = String
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SValue r -> SValue r -> SValue r
CP.indexOf String
csIndex

instance Set CSharpCode where
  contains :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
contains = String
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SValue r -> SValue r -> SValue r
CP.contains String
csContains
  setAdd :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
setAdd = String
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SValue r -> SValue r -> SValue r
CP.setMethodCall String
csListAppend
  setRemove :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
setRemove = String
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SValue r -> SValue r -> SValue r
CP.setMethodCall String
csListRemove
  setUnion :: SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
setUnion = String
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SValue r -> SValue r -> SValue r
CP.setMethodCall String
csUnionWith

instance InternalList CSharpCode where
  listSlice' :: Maybe (SValue CSharpCode)
-> Maybe (SValue CSharpCode)
-> Maybe (SValue CSharpCode)
-> SVariable CSharpCode
-> SValue CSharpCode
-> MSBlock CSharpCode
listSlice' = Maybe (SValue CSharpCode)
-> Maybe (SValue CSharpCode)
-> Maybe (SValue CSharpCode)
-> SVariable CSharpCode
-> SValue CSharpCode
-> MSBlock CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Maybe (SValue r)
-> Maybe (SValue r)
-> Maybe (SValue r)
-> SVariable r
-> SValue r
-> MSBlock r
M.listSlice

instance InternalGetSet CSharpCode where
  getFunc :: SVariable CSharpCode -> VSFunction CSharpCode
getFunc = SVariable CSharpCode -> VSFunction CSharpCode
forall (r :: * -> *). OORenderSym r => SVariable r -> VSFunction r
G.getFunc
  setFunc :: VSType CSharpCode
-> SVariable CSharpCode
-> SValue CSharpCode
-> VSFunction CSharpCode
setFunc = VSType CSharpCode
-> SVariable CSharpCode
-> SValue CSharpCode
-> VSFunction CSharpCode
forall (r :: * -> *).
OORenderSym r =>
VSType r -> SVariable r -> SValue r -> VSFunction r
G.setFunc

instance InternalListFunc CSharpCode where
  listSizeFunc :: SValue CSharpCode -> VSFunction CSharpCode
listSizeFunc SValue CSharpCode
_ = Doc -> VSType CSharpCode -> VSFunction CSharpCode
forall (r :: * -> *).
RenderFunction r =>
Doc -> VSType r -> VSFunction r
funcFromData (Doc -> Doc
R.func Doc
csListSize) VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
int
  listAddFunc :: SValue CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> VSFunction CSharpCode
listAddFunc SValue CSharpCode
_ = String
-> SValue CSharpCode -> SValue CSharpCode -> VSFunction CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SValue r -> SValue r -> VSFunction r
CP.listAddFunc String
csListAdd
  listAppendFunc :: SValue CSharpCode -> SValue CSharpCode -> VSFunction CSharpCode
listAppendFunc SValue CSharpCode
_ = String -> SValue CSharpCode -> VSFunction CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SValue r -> VSFunction r
G.listAppendFunc String
csListAppend
  listAccessFunc :: VSType CSharpCode -> SValue CSharpCode -> VSFunction CSharpCode
listAccessFunc = VSType CSharpCode -> SValue CSharpCode -> VSFunction CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSType r -> SValue r -> VSFunction r
CP.listAccessFunc
  listSetFunc :: SValue CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> VSFunction CSharpCode
listSetFunc = (Doc -> Doc -> Doc)
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> VSFunction CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(Doc -> Doc -> Doc)
-> SValue r -> SValue r -> SValue r -> VSFunction r
CP.listSetFunc Doc -> Doc -> Doc
R.listSetFunc

instance ThunkSym CSharpCode where
  type Thunk CSharpCode = CommonThunk VS

instance ThunkAssign CSharpCode where
  thunkAssign :: SVariable CSharpCode
-> VSThunk CSharpCode -> MSStatement CSharpCode
thunkAssign SVariable CSharpCode
v VSThunk CSharpCode
t = do
    String
iName <- MS String
genLoopIndex
    let
      i :: SVariable CSharpCode
i = String -> VSType CSharpCode -> SVariable CSharpCode
forall (r :: * -> *).
VariableSym r =>
String -> VSType r -> SVariable r
var String
iName VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
int
      dim :: VS (CSharpCode ValData)
dim = (ValData -> CSharpCode ValData)
-> StateT ValueState Identity ValData -> VS (CSharpCode ValData)
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ValData -> CSharpCode ValData
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StateT ValueState Identity ValData -> VS (CSharpCode ValData))
-> StateT ValueState Identity ValData -> VS (CSharpCode ValData)
forall a b. (a -> b) -> a -> b
$ StateT
  ValueState
  Identity
  (CSharpCode (CommonThunk (StateT ValueState Identity)))
VSThunk CSharpCode
t StateT
  ValueState
  Identity
  (CSharpCode (CommonThunk (StateT ValueState Identity)))
-> (CSharpCode (CommonThunk (StateT ValueState Identity))
    -> StateT ValueState Identity ValData)
-> StateT ValueState Identity ValData
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
>>= (StateT ValueState Identity ValData
 -> StateT ValueState Identity ValData)
-> CommonThunk (StateT ValueState Identity)
-> StateT ValueState Identity ValData
forall (s :: * -> *).
(s ValData -> s ValData) -> CommonThunk s -> s ValData
commonThunkDim ((CSharpCode ValData -> ValData)
-> VS (CSharpCode ValData) -> StateT ValueState Identity ValData
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CSharpCode ValData -> ValData
forall a. CSharpCode a -> a
unCSC (VS (CSharpCode ValData) -> StateT ValueState Identity ValData)
-> (StateT ValueState Identity ValData -> VS (CSharpCode ValData))
-> StateT ValueState Identity ValData
-> StateT ValueState Identity ValData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VS (CSharpCode ValData) -> VS (CSharpCode ValData)
SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). List r => SValue r -> SValue r
listSize (VS (CSharpCode ValData) -> VS (CSharpCode ValData))
-> (StateT ValueState Identity ValData -> VS (CSharpCode ValData))
-> StateT ValueState Identity ValData
-> VS (CSharpCode ValData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ValData -> CSharpCode ValData)
-> StateT ValueState Identity ValData -> VS (CSharpCode ValData)
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ValData -> CSharpCode ValData
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure) (CommonThunk (StateT ValueState Identity)
 -> StateT ValueState Identity ValData)
-> (CSharpCode (CommonThunk (StateT ValueState Identity))
    -> CommonThunk (StateT ValueState Identity))
-> CSharpCode (CommonThunk (StateT ValueState Identity))
-> StateT ValueState Identity ValData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode (CommonThunk (StateT ValueState Identity))
-> CommonThunk (StateT ValueState Identity)
forall a. CSharpCode a -> a
unCSC
      loopInit :: MSStatement CSharpCode
loopInit = LensLike'
  (Zoomed
     (StateT ValueState Identity)
     (CommonThunk (StateT ValueState Identity)))
  MethodState
  ValueState
-> StateT
     ValueState Identity (CommonThunk (StateT ValueState Identity))
-> StateT
     MethodState Identity (CommonThunk (StateT ValueState Identity))
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)
     (CommonThunk (StateT ValueState Identity)))
  MethodState
  ValueState
(ValueState
 -> Focusing
      Identity (CommonThunk (StateT ValueState Identity)) ValueState)
-> MethodState
-> Focusing
     Identity (CommonThunk (StateT ValueState Identity)) MethodState
Lens' MethodState ValueState
lensMStoVS ((CSharpCode (CommonThunk (StateT ValueState Identity))
 -> CommonThunk (StateT ValueState Identity))
-> StateT
     ValueState
     Identity
     (CSharpCode (CommonThunk (StateT ValueState Identity)))
-> StateT
     ValueState Identity (CommonThunk (StateT ValueState Identity))
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CSharpCode (CommonThunk (StateT ValueState Identity))
-> CommonThunk (StateT ValueState Identity)
forall a. CSharpCode a -> a
unCSC StateT
  ValueState
  Identity
  (CSharpCode (CommonThunk (StateT ValueState Identity)))
VSThunk CSharpCode
t) StateT
  MethodState Identity (CommonThunk (StateT ValueState Identity))
-> (CommonThunk (StateT ValueState Identity)
    -> MSStatement CSharpCode)
-> MSStatement CSharpCode
forall a b.
StateT MethodState Identity a
-> (a -> StateT MethodState Identity b)
-> StateT MethodState Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (CommonThunk (StateT ValueState Identity)
 -> MSStatement CSharpCode)
-> (CommonThunk (StateT ValueState Identity)
    -> MSStatement CSharpCode)
-> CommonThunk (StateT ValueState Identity)
-> MSStatement CSharpCode
forall (s :: * -> *) a.
(CommonThunk s -> a) -> (CommonThunk s -> a) -> CommonThunk s -> a
commonThunkElim
        (MSStatement CSharpCode
-> CommonThunk (StateT ValueState Identity)
-> MSStatement CSharpCode
forall a b. a -> b -> a
const MSStatement CSharpCode
forall (r :: * -> *). StatementSym r => MSStatement r
emptyStmt) (MSStatement CSharpCode
-> CommonThunk (StateT ValueState Identity)
-> MSStatement CSharpCode
forall a b. a -> b -> a
const (MSStatement CSharpCode
 -> CommonThunk (StateT ValueState Identity)
 -> MSStatement CSharpCode)
-> MSStatement CSharpCode
-> CommonThunk (StateT ValueState Identity)
-> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
assign SVariable CSharpCode
v (SValue CSharpCode -> MSStatement CSharpCode)
-> SValue CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ VSType CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
(TypeElim r, Literal r) =>
VSType r -> SValue r
litZero (VSType CSharpCode -> SValue CSharpCode)
-> VSType CSharpCode -> SValue CSharpCode
forall a b. (a -> b) -> a -> b
$ (CSharpCode (Variable CSharpCode) -> CSharpCode TypeData)
-> SVariable CSharpCode -> VS (CSharpCode TypeData)
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CSharpCode (Variable CSharpCode) -> CSharpCode TypeData
CSharpCode (Variable CSharpCode) -> CSharpCode (Type CSharpCode)
forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable CSharpCode
v)
      loopBody :: MSStatement CSharpCode
loopBody = LensLike'
  (Zoomed
     (StateT ValueState Identity)
     (CommonThunk (StateT ValueState Identity)))
  MethodState
  ValueState
-> StateT
     ValueState Identity (CommonThunk (StateT ValueState Identity))
-> StateT
     MethodState Identity (CommonThunk (StateT ValueState Identity))
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)
     (CommonThunk (StateT ValueState Identity)))
  MethodState
  ValueState
(ValueState
 -> Focusing
      Identity (CommonThunk (StateT ValueState Identity)) ValueState)
-> MethodState
-> Focusing
     Identity (CommonThunk (StateT ValueState Identity)) MethodState
Lens' MethodState ValueState
lensMStoVS ((CSharpCode (CommonThunk (StateT ValueState Identity))
 -> CommonThunk (StateT ValueState Identity))
-> StateT
     ValueState
     Identity
     (CSharpCode (CommonThunk (StateT ValueState Identity)))
-> StateT
     ValueState Identity (CommonThunk (StateT ValueState Identity))
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CSharpCode (CommonThunk (StateT ValueState Identity))
-> CommonThunk (StateT ValueState Identity)
forall a. CSharpCode a -> a
unCSC StateT
  ValueState
  Identity
  (CSharpCode (CommonThunk (StateT ValueState Identity)))
VSThunk CSharpCode
t) StateT
  MethodState Identity (CommonThunk (StateT ValueState Identity))
-> (CommonThunk (StateT ValueState Identity)
    -> MSStatement CSharpCode)
-> MSStatement CSharpCode
forall a b.
StateT MethodState Identity a
-> (a -> StateT MethodState Identity b)
-> StateT MethodState Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (CommonThunk (StateT ValueState Identity)
 -> MSStatement CSharpCode)
-> (CommonThunk (StateT ValueState Identity)
    -> MSStatement CSharpCode)
-> CommonThunk (StateT ValueState Identity)
-> MSStatement CSharpCode
forall (s :: * -> *) a.
(CommonThunk s -> a) -> (CommonThunk s -> a) -> CommonThunk s -> a
commonThunkElim
        (SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *). StatementSym r => SValue r -> MSStatement r
valStmt (SValue CSharpCode -> MSStatement CSharpCode)
-> (CommonThunk (StateT ValueState Identity) -> SValue CSharpCode)
-> CommonThunk (StateT ValueState Identity)
-> MSStatement CSharpCode
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SValue CSharpCode
-> SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
List r =>
SValue r -> SValue r -> SValue r -> SValue r
listSet (SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable CSharpCode
v) (SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable CSharpCode
i) (VS (CSharpCode ValData) -> SValue CSharpCode)
-> (CommonThunk (StateT ValueState Identity)
    -> VS (CSharpCode ValData))
-> CommonThunk (StateT ValueState Identity)
-> SValue CSharpCode
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SValue CSharpCode -> VSThunk CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
VectorExpression r =>
SValue r -> VSThunk r -> SValue r
vecIndex (SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable CSharpCode
i) (StateT
   ValueState
   Identity
   (CSharpCode (CommonThunk (StateT ValueState Identity)))
 -> VS (CSharpCode ValData))
-> (CommonThunk (StateT ValueState Identity)
    -> StateT
         ValueState
         Identity
         (CSharpCode (CommonThunk (StateT ValueState Identity))))
-> CommonThunk (StateT ValueState Identity)
-> VS (CSharpCode ValData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode (CommonThunk (StateT ValueState Identity))
-> StateT
     ValueState
     Identity
     (CSharpCode (CommonThunk (StateT ValueState Identity)))
forall a. a -> StateT ValueState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CSharpCode (CommonThunk (StateT ValueState Identity))
 -> StateT
      ValueState
      Identity
      (CSharpCode (CommonThunk (StateT ValueState Identity))))
-> (CommonThunk (StateT ValueState Identity)
    -> CSharpCode (CommonThunk (StateT ValueState Identity)))
-> CommonThunk (StateT ValueState Identity)
-> StateT
     ValueState
     Identity
     (CSharpCode (CommonThunk (StateT ValueState Identity)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CommonThunk (StateT ValueState Identity)
-> CSharpCode (CommonThunk (StateT ValueState Identity))
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure)
        ((SVariable CSharpCode
v &+=) (VS (CSharpCode ValData) -> MSStatement CSharpCode)
-> (CommonThunk (StateT ValueState Identity)
    -> VS (CSharpCode ValData))
-> CommonThunk (StateT ValueState Identity)
-> MSStatement CSharpCode
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SValue CSharpCode -> VSThunk CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
VectorExpression r =>
SValue r -> VSThunk r -> SValue r
vecIndex (SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable CSharpCode
i) (StateT
   ValueState
   Identity
   (CSharpCode (CommonThunk (StateT ValueState Identity)))
 -> VS (CSharpCode ValData))
-> (CommonThunk (StateT ValueState Identity)
    -> StateT
         ValueState
         Identity
         (CSharpCode (CommonThunk (StateT ValueState Identity))))
-> CommonThunk (StateT ValueState Identity)
-> VS (CSharpCode ValData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode (CommonThunk (StateT ValueState Identity))
-> StateT
     ValueState
     Identity
     (CSharpCode (CommonThunk (StateT ValueState Identity)))
forall a. a -> StateT ValueState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CSharpCode (CommonThunk (StateT ValueState Identity))
 -> StateT
      ValueState
      Identity
      (CSharpCode (CommonThunk (StateT ValueState Identity))))
-> (CommonThunk (StateT ValueState Identity)
    -> CSharpCode (CommonThunk (StateT ValueState Identity)))
-> CommonThunk (StateT ValueState Identity)
-> StateT
     ValueState
     Identity
     (CSharpCode (CommonThunk (StateT ValueState Identity)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CommonThunk (StateT ValueState Identity)
-> CSharpCode (CommonThunk (StateT ValueState Identity))
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure)
    [MSStatement CSharpCode] -> MSStatement CSharpCode
forall (r :: * -> *).
StatementSym r =>
[MSStatement r] -> MSStatement r
multi [MSStatement CSharpCode
loopInit,
      SVariable CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> MSBody CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
ControlStatement r =>
SVariable r
-> SValue r -> SValue r -> SValue r -> MSBody r -> MSStatement r
forRange SVariable CSharpCode
i (Integer -> SValue CSharpCode
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
0) VS (CSharpCode ValData)
SValue CSharpCode
dim (Integer -> SValue CSharpCode
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
1) (MSBody CSharpCode -> MSStatement CSharpCode)
-> MSBody CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ [MSBlock CSharpCode] -> MSBody CSharpCode
forall (r :: * -> *). BodySym r => [MSBlock r] -> MSBody r
body [[MSStatement CSharpCode] -> MSBlock CSharpCode
forall (r :: * -> *). BlockSym r => [MSStatement r] -> MSBlock r
block [MSStatement CSharpCode
loopBody]]]

instance VectorType CSharpCode where
  vecType :: VSType CSharpCode -> VSType CSharpCode
vecType = VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r -> VSType r
listType

instance VectorDecl CSharpCode where
  vecDec :: Integer
-> SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> MSStatement CSharpCode
vecDec = Integer
-> SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> MSStatement CSharpCode
forall (r :: * -> *).
DeclStatement r =>
Integer -> SVariable r -> r (Scope r) -> MSStatement r
listDec
  vecDecDef :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SValue CSharpCode]
-> MSStatement CSharpCode
vecDecDef = SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SValue CSharpCode]
-> MSStatement CSharpCode
forall (r :: * -> *).
DeclStatement r =>
SVariable r -> r (Scope r) -> [SValue r] -> MSStatement r
listDecDef

instance VectorThunk CSharpCode where
  vecThunk :: SVariable CSharpCode -> VSThunk CSharpCode
vecThunk = CSharpCode (CommonThunk (StateT ValueState Identity))
-> StateT
     ValueState
     Identity
     (CSharpCode (CommonThunk (StateT ValueState Identity)))
forall a. a -> StateT ValueState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CSharpCode (CommonThunk (StateT ValueState Identity))
 -> StateT
      ValueState
      Identity
      (CSharpCode (CommonThunk (StateT ValueState Identity))))
-> (State ValueState (CSharpCode VarData)
    -> CSharpCode (CommonThunk (StateT ValueState Identity)))
-> State ValueState (CSharpCode VarData)
-> StateT
     ValueState
     Identity
     (CSharpCode (CommonThunk (StateT ValueState Identity)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CommonThunk (StateT ValueState Identity)
-> CSharpCode (CommonThunk (StateT ValueState Identity))
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CommonThunk (StateT ValueState Identity)
 -> CSharpCode (CommonThunk (StateT ValueState Identity)))
-> (State ValueState (CSharpCode VarData)
    -> CommonThunk (StateT ValueState Identity))
-> State ValueState (CSharpCode VarData)
-> CSharpCode (CommonThunk (StateT ValueState Identity))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StateT ValueState Identity ValData
-> CommonThunk (StateT ValueState Identity)
forall (s :: * -> *). s ValData -> CommonThunk s
pureValue (StateT ValueState Identity ValData
 -> CommonThunk (StateT ValueState Identity))
-> (State ValueState (CSharpCode VarData)
    -> StateT ValueState Identity ValData)
-> State ValueState (CSharpCode VarData)
-> CommonThunk (StateT ValueState Identity)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CSharpCode ValData -> ValData)
-> VS (CSharpCode ValData) -> StateT ValueState Identity ValData
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CSharpCode ValData -> ValData
forall a. CSharpCode a -> a
unCSC (VS (CSharpCode ValData) -> StateT ValueState Identity ValData)
-> (State ValueState (CSharpCode VarData)
    -> VS (CSharpCode ValData))
-> State ValueState (CSharpCode VarData)
-> StateT ValueState Identity ValData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. State ValueState (CSharpCode VarData) -> VS (CSharpCode ValData)
SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf

instance VectorExpression CSharpCode where
  vecScale :: SValue CSharpCode -> VSThunk CSharpCode -> VSThunk CSharpCode
vecScale SValue CSharpCode
k = (CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode))
-> VSThunk CSharpCode -> VSThunk CSharpCode
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode))
 -> VSThunk CSharpCode -> VSThunk CSharpCode)
-> (CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode))
-> VSThunk CSharpCode
-> VSThunk CSharpCode
forall a b. (a -> b) -> a -> b
$ (Thunk CSharpCode -> Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode)
forall a b. (a -> b) -> CSharpCode a -> CSharpCode b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Thunk CSharpCode -> Thunk CSharpCode)
 -> CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode))
-> (Thunk CSharpCode -> Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
forall a b. (a -> b) -> a -> b
$ (StateT ValueState Identity ValData
 -> StateT ValueState Identity ValData)
-> CommonThunk (StateT ValueState Identity)
-> CommonThunk (StateT ValueState Identity)
forall (s :: * -> *).
(s ValData -> s ValData) -> CommonThunk s -> CommonThunk s
vectorize ((CSharpCode ValData -> ValData)
-> VS (CSharpCode ValData) -> StateT ValueState Identity ValData
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CSharpCode ValData -> ValData
forall a. CSharpCode a -> a
unCSC (VS (CSharpCode ValData) -> StateT ValueState Identity ValData)
-> (StateT ValueState Identity ValData -> VS (CSharpCode ValData))
-> StateT ValueState Identity ValData
-> StateT ValueState Identity ValData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SValue CSharpCode
k #*) (VS (CSharpCode ValData) -> VS (CSharpCode ValData))
-> (StateT ValueState Identity ValData -> VS (CSharpCode ValData))
-> StateT ValueState Identity ValData
-> VS (CSharpCode ValData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ValData -> CSharpCode ValData)
-> StateT ValueState Identity ValData -> VS (CSharpCode ValData)
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ValData -> CSharpCode ValData
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure)
  vecAdd :: VSThunk CSharpCode -> VSThunk CSharpCode -> VSThunk CSharpCode
vecAdd = (CSharpCode (Thunk CSharpCode)
 -> CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode))
-> VSThunk CSharpCode -> VSThunk CSharpCode -> VSThunk CSharpCode
forall a b c.
(a -> b -> c)
-> StateT ValueState Identity a
-> StateT ValueState Identity b
-> StateT ValueState Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 ((CSharpCode (Thunk CSharpCode)
  -> CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode))
 -> VSThunk CSharpCode -> VSThunk CSharpCode -> VSThunk CSharpCode)
-> (CSharpCode (Thunk CSharpCode)
    -> CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode))
-> VSThunk CSharpCode
-> VSThunk CSharpCode
-> VSThunk CSharpCode
forall a b. (a -> b) -> a -> b
$ (Thunk CSharpCode -> Thunk CSharpCode -> Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
forall a b c.
(a -> b -> c) -> CSharpCode a -> CSharpCode b -> CSharpCode c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 ((Thunk CSharpCode -> Thunk CSharpCode -> Thunk CSharpCode)
 -> CSharpCode (Thunk CSharpCode)
 -> CSharpCode (Thunk CSharpCode)
 -> CSharpCode (Thunk CSharpCode))
-> (Thunk CSharpCode -> Thunk CSharpCode -> Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
forall a b. (a -> b) -> a -> b
$ (StateT ValueState Identity ValData
 -> StateT ValueState Identity ValData
 -> StateT ValueState Identity ValData)
-> CommonThunk (StateT ValueState Identity)
-> CommonThunk (StateT ValueState Identity)
-> CommonThunk (StateT ValueState Identity)
forall (s :: * -> *).
(s ValData -> s ValData -> s ValData)
-> CommonThunk s -> CommonThunk s -> CommonThunk s
vectorize2 (\StateT ValueState Identity ValData
v1 StateT ValueState Identity ValData
v2 -> (CSharpCode ValData -> ValData)
-> VS (CSharpCode ValData) -> StateT ValueState Identity ValData
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CSharpCode ValData -> ValData
forall a. CSharpCode a -> a
unCSC (VS (CSharpCode ValData) -> StateT ValueState Identity ValData)
-> VS (CSharpCode ValData) -> StateT ValueState Identity ValData
forall a b. (a -> b) -> a -> b
$ (ValData -> CSharpCode ValData)
-> StateT ValueState Identity ValData -> VS (CSharpCode ValData)
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ValData -> CSharpCode ValData
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure StateT ValueState Identity ValData
v1 SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
NumericExpression r =>
SValue r -> SValue r -> SValue r
#+ (ValData -> CSharpCode ValData)
-> StateT ValueState Identity ValData -> VS (CSharpCode ValData)
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ValData -> CSharpCode ValData
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure StateT ValueState Identity ValData
v2)
  vecIndex :: SValue CSharpCode -> VSThunk CSharpCode -> SValue CSharpCode
vecIndex SValue CSharpCode
i = (VSThunk CSharpCode
-> (CSharpCode (Thunk CSharpCode) -> SValue CSharpCode)
-> SValue CSharpCode
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
>>= (ValData -> CSharpCode ValData)
-> StateT ValueState Identity ValData -> VS (CSharpCode ValData)
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ValData -> CSharpCode ValData
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StateT ValueState Identity ValData -> VS (CSharpCode ValData))
-> (CSharpCode (CommonThunk (StateT ValueState Identity))
    -> StateT ValueState Identity ValData)
-> CSharpCode (CommonThunk (StateT ValueState Identity))
-> VS (CSharpCode ValData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StateT ValueState Identity ValData
 -> StateT ValueState Identity ValData)
-> CommonThunk (StateT ValueState Identity)
-> StateT ValueState Identity ValData
forall (s :: * -> *).
(s ValData -> s ValData) -> CommonThunk s -> s ValData
commonVecIndex ((CSharpCode ValData -> ValData)
-> VS (CSharpCode ValData) -> StateT ValueState Identity ValData
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CSharpCode ValData -> ValData
forall a. CSharpCode a -> a
unCSC (VS (CSharpCode ValData) -> StateT ValueState Identity ValData)
-> (StateT ValueState Identity ValData -> VS (CSharpCode ValData))
-> StateT ValueState Identity ValData
-> StateT ValueState Identity ValData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VS (CSharpCode ValData)
 -> VS (CSharpCode ValData) -> VS (CSharpCode ValData))
-> VS (CSharpCode ValData)
-> VS (CSharpCode ValData)
-> VS (CSharpCode ValData)
forall a b c. (a -> b -> c) -> b -> a -> c
flip VS (CSharpCode ValData)
-> VS (CSharpCode ValData) -> VS (CSharpCode ValData)
SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). List r => SValue r -> SValue r -> SValue r
listAccess VS (CSharpCode ValData)
SValue CSharpCode
i (VS (CSharpCode ValData) -> VS (CSharpCode ValData))
-> (StateT ValueState Identity ValData -> VS (CSharpCode ValData))
-> StateT ValueState Identity ValData
-> VS (CSharpCode ValData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ValData -> CSharpCode ValData)
-> StateT ValueState Identity ValData -> VS (CSharpCode ValData)
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ValData -> CSharpCode ValData
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure) (CommonThunk (StateT ValueState Identity)
 -> StateT ValueState Identity ValData)
-> (CSharpCode (CommonThunk (StateT ValueState Identity))
    -> CommonThunk (StateT ValueState Identity))
-> CSharpCode (CommonThunk (StateT ValueState Identity))
-> StateT ValueState Identity ValData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode (CommonThunk (StateT ValueState Identity))
-> CommonThunk (StateT ValueState Identity)
forall a. CSharpCode a -> a
unCSC)
  vecDot :: VSThunk CSharpCode -> VSThunk CSharpCode -> VSThunk CSharpCode
vecDot = (CSharpCode (Thunk CSharpCode)
 -> CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode))
-> VSThunk CSharpCode -> VSThunk CSharpCode -> VSThunk CSharpCode
forall a b c.
(a -> b -> c)
-> StateT ValueState Identity a
-> StateT ValueState Identity b
-> StateT ValueState Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 ((CSharpCode (Thunk CSharpCode)
  -> CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode))
 -> VSThunk CSharpCode -> VSThunk CSharpCode -> VSThunk CSharpCode)
-> (CSharpCode (Thunk CSharpCode)
    -> CSharpCode (Thunk CSharpCode) -> CSharpCode (Thunk CSharpCode))
-> VSThunk CSharpCode
-> VSThunk CSharpCode
-> VSThunk CSharpCode
forall a b. (a -> b) -> a -> b
$ (Thunk CSharpCode -> Thunk CSharpCode -> Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
forall a b c.
(a -> b -> c) -> CSharpCode a -> CSharpCode b -> CSharpCode c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 ((Thunk CSharpCode -> Thunk CSharpCode -> Thunk CSharpCode)
 -> CSharpCode (Thunk CSharpCode)
 -> CSharpCode (Thunk CSharpCode)
 -> CSharpCode (Thunk CSharpCode))
-> (Thunk CSharpCode -> Thunk CSharpCode -> Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
-> CSharpCode (Thunk CSharpCode)
forall a b. (a -> b) -> a -> b
$ (CommonThunk (StateT ValueState Identity)
 -> CommonThunk (StateT ValueState Identity))
-> (CommonThunk (StateT ValueState Identity)
    -> CommonThunk (StateT ValueState Identity))
-> CommonThunk (StateT ValueState Identity)
-> CommonThunk (StateT ValueState Identity)
forall a b.
(a -> b)
-> (CommonThunk (StateT ValueState Identity) -> a)
-> CommonThunk (StateT ValueState Identity)
-> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CommonThunk (StateT ValueState Identity)
-> CommonThunk (StateT ValueState Identity)
forall (s :: * -> *). CommonThunk s -> CommonThunk s
sumComponents ((CommonThunk (StateT ValueState Identity)
  -> CommonThunk (StateT ValueState Identity))
 -> CommonThunk (StateT ValueState Identity)
 -> CommonThunk (StateT ValueState Identity))
-> (CommonThunk (StateT ValueState Identity)
    -> CommonThunk (StateT ValueState Identity)
    -> CommonThunk (StateT ValueState Identity))
-> CommonThunk (StateT ValueState Identity)
-> CommonThunk (StateT ValueState Identity)
-> CommonThunk (StateT ValueState Identity)
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
<$> (StateT ValueState Identity ValData
 -> StateT ValueState Identity ValData
 -> StateT ValueState Identity ValData)
-> CommonThunk (StateT ValueState Identity)
-> CommonThunk (StateT ValueState Identity)
-> CommonThunk (StateT ValueState Identity)
forall (s :: * -> *).
(s ValData -> s ValData -> s ValData)
-> CommonThunk s -> CommonThunk s -> CommonThunk s
vectorize2 (\StateT ValueState Identity ValData
v1 StateT ValueState Identity ValData
v2 -> (CSharpCode ValData -> ValData)
-> VS (CSharpCode ValData) -> StateT ValueState Identity ValData
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CSharpCode ValData -> ValData
forall a. CSharpCode a -> a
unCSC (VS (CSharpCode ValData) -> StateT ValueState Identity ValData)
-> VS (CSharpCode ValData) -> StateT ValueState Identity ValData
forall a b. (a -> b) -> a -> b
$ (ValData -> CSharpCode ValData)
-> StateT ValueState Identity ValData -> VS (CSharpCode ValData)
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ValData -> CSharpCode ValData
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure StateT ValueState Identity ValData
v1 SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
NumericExpression r =>
SValue r -> SValue r -> SValue r
#* (ValData -> CSharpCode ValData)
-> StateT ValueState Identity ValData -> VS (CSharpCode ValData)
forall a b.
(a -> b)
-> StateT ValueState Identity a -> StateT ValueState Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ValData -> CSharpCode ValData
forall a. a -> CSharpCode a
forall (f :: * -> *) a. Applicative f => a -> f a
pure StateT ValueState Identity ValData
v2)

instance RenderFunction CSharpCode where
  funcFromData :: Doc -> VSType CSharpCode -> VSFunction CSharpCode
funcFromData Doc
d = (CSharpCode TypeData -> CSharpCode FuncData)
-> VS (CSharpCode TypeData)
-> State ValueState (CSharpCode FuncData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue ((TypeData -> FuncData)
-> CSharpCode TypeData -> CSharpCode FuncData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue (TypeData -> Doc -> FuncData
`fd` Doc
d))
  
instance FunctionElim CSharpCode where
  functionType :: CSharpCode (Function CSharpCode) -> CSharpCode (Type CSharpCode)
functionType = (FuncData -> TypeData)
-> CSharpCode FuncData -> CSharpCode TypeData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue FuncData -> TypeData
fType
  function :: CSharpCode (Function CSharpCode) -> Doc
function = FuncData -> Doc
funcDoc (FuncData -> Doc)
-> (CSharpCode FuncData -> FuncData) -> CSharpCode FuncData -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode FuncData -> FuncData
forall a. CSharpCode a -> a
unCSC

instance InternalAssignStmt CSharpCode where
  multiAssign :: [SVariable CSharpCode]
-> [SValue CSharpCode] -> MSStatement CSharpCode
multiAssign [SVariable CSharpCode]
_ [SValue CSharpCode]
_ = String -> MSStatement CSharpCode
forall a. HasCallStack => String -> a
error (String -> MSStatement CSharpCode)
-> String -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ String -> String
C.multiAssignError String
csName

instance InternalIOStmt CSharpCode where
  printSt :: Bool
-> Maybe (SValue CSharpCode)
-> SValue CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
printSt Bool
_ Maybe (SValue CSharpCode)
_ = SValue CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SValue r -> SValue r -> MSStatement r
CP.printSt
  
instance InternalControlStmt CSharpCode where
  multiReturn :: [SValue CSharpCode] -> MSStatement CSharpCode
multiReturn [SValue CSharpCode]
_ = String -> MSStatement CSharpCode
forall a. HasCallStack => String -> a
error (String -> MSStatement CSharpCode)
-> String -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ String -> String
C.multiReturnError String
csName 

instance RenderStatement CSharpCode where
  stmt :: MSStatement CSharpCode -> MSStatement CSharpCode
stmt = MSStatement CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
MSStatement r -> MSStatement r
G.stmt
  loopStmt :: MSStatement CSharpCode -> MSStatement CSharpCode
loopStmt = MSStatement CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
MSStatement r -> MSStatement r
G.loopStmt
  stmtFromData :: Doc -> Terminator -> MSStatement CSharpCode
stmtFromData Doc
d Terminator
t = CSharpCode (Statement CSharpCode) -> MSStatement CSharpCode
forall a s. a -> State s a
toState (CSharpCode (Statement CSharpCode) -> MSStatement CSharpCode)
-> CSharpCode (Statement CSharpCode) -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ (Doc, Terminator) -> CSharpCode (Doc, Terminator)
forall (r :: * -> *) a. Monad r => a -> r a
toCode (Doc
d, Terminator
t)

instance StatementElim CSharpCode where
  statement :: CSharpCode (Statement CSharpCode) -> Doc
statement = (Doc, Terminator) -> Doc
forall a b. (a, b) -> a
fst ((Doc, Terminator) -> Doc)
-> (CSharpCode (Doc, Terminator) -> (Doc, Terminator))
-> CSharpCode (Doc, Terminator)
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode (Doc, Terminator) -> (Doc, Terminator)
forall a. CSharpCode a -> a
unCSC
  statementTerm :: CSharpCode (Statement CSharpCode) -> Terminator
statementTerm = (Doc, Terminator) -> Terminator
forall a b. (a, b) -> b
snd ((Doc, Terminator) -> Terminator)
-> (CSharpCode (Doc, Terminator) -> (Doc, Terminator))
-> CSharpCode (Doc, Terminator)
-> Terminator
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode (Doc, Terminator) -> (Doc, Terminator)
forall a. CSharpCode a -> a
unCSC

instance StatementSym CSharpCode where
  type Statement CSharpCode = (Doc, Terminator)
  valStmt :: SValue CSharpCode -> MSStatement CSharpCode
valStmt = Terminator -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Terminator -> SValue r -> MSStatement r
G.valStmt Terminator
Semi
  emptyStmt :: MSStatement CSharpCode
emptyStmt = MSStatement CSharpCode
forall (r :: * -> *). CommonRenderSym r => MSStatement r
G.emptyStmt
  multi :: [MSStatement CSharpCode] -> MSStatement CSharpCode
multi = ([CSharpCode (Doc, Terminator)] -> CSharpCode (Doc, Terminator))
-> [StateT MethodState Identity (CSharpCode (Doc, Terminator))]
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
forall a b s. ([a] -> b) -> [State s a] -> State s b
onStateList (([(Doc, Terminator)] -> (Doc, Terminator))
-> [CSharpCode (Doc, Terminator)] -> CSharpCode (Doc, Terminator)
forall (m :: * -> *) a b. Monad m => ([a] -> b) -> [m a] -> m b
onCodeList [(Doc, Terminator)] -> (Doc, Terminator)
R.multiStmt)

instance AssignStatement CSharpCode where
  assign :: SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
assign = Terminator
-> SVariable CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Terminator -> SVariable r -> SValue r -> MSStatement r
G.assign Terminator
Semi
  &-= :: SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
(&-=) = Terminator
-> SVariable CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Terminator -> SVariable r -> SValue r -> MSStatement r
G.subAssign Terminator
Semi
  &+= :: SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
(&+=) = SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SVariable r -> SValue r -> MSStatement r
G.increment
  &++ :: SVariable CSharpCode -> MSStatement CSharpCode
(&++) = SVariable CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SVariable r -> MSStatement r
C.increment1
  &-- :: SVariable CSharpCode -> MSStatement CSharpCode
(&--) = SVariable CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SVariable r -> MSStatement r
C.decrement1

instance DeclStatement CSharpCode where
  varDec :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode) -> MSStatement CSharpCode
varDec SVariable CSharpCode
v CSharpCode (Scope CSharpCode)
scp = LensLike'
  (Zoomed (StateT ValueState Identity) (CSharpCode VarData))
  MethodState
  ValueState
-> State ValueState (CSharpCode VarData)
-> StateT MethodState Identity (CSharpCode VarData)
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) (CSharpCode VarData))
  MethodState
  ValueState
(ValueState -> Focusing Identity (CSharpCode VarData) ValueState)
-> MethodState
-> Focusing Identity (CSharpCode VarData) MethodState
Lens' MethodState ValueState
lensMStoVS State ValueState (CSharpCode VarData)
SVariable CSharpCode
v StateT MethodState Identity (CSharpCode VarData)
-> (CSharpCode VarData
    -> StateT MethodState Identity (CSharpCode (Doc, Terminator)))
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
forall a b.
StateT MethodState Identity a
-> (a -> StateT MethodState Identity b)
-> StateT MethodState Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (\CSharpCode VarData
v' -> Binding -> MSStatement CSharpCode -> MSStatement CSharpCode
csVarDec (CSharpCode (Variable CSharpCode) -> Binding
forall (r :: * -> *).
InternalVarElim r =>
r (Variable r) -> Binding
variableBind CSharpCode VarData
CSharpCode (Variable CSharpCode)
v') (MSStatement CSharpCode -> MSStatement CSharpCode)
-> MSStatement CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ 
    CSharpCode (Permanence CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> Doc
-> SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> MSStatement CSharpCode
forall (r :: * -> *).
OORenderSym r =>
r (Permanence r)
-> r (Permanence r)
-> Doc
-> SVariable r
-> r (Scope r)
-> MSStatement r
C.varDec CSharpCode (Permanence CSharpCode)
forall (r :: * -> *). PermanenceSym r => r (Permanence r)
static CSharpCode (Permanence CSharpCode)
forall (r :: * -> *). PermanenceSym r => r (Permanence r)
dynamic Doc
empty SVariable CSharpCode
v CSharpCode (Scope CSharpCode)
scp)
  varDecDef :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> SValue CSharpCode
-> MSStatement CSharpCode
varDecDef = Terminator
-> SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Terminator
-> SVariable r -> r (Scope r) -> SValue r -> MSStatement r
C.varDecDef Terminator
Semi
  setDec :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode) -> MSStatement CSharpCode
setDec = SVariable CSharpCode
-> CSharpCode (Scope CSharpCode) -> MSStatement CSharpCode
forall (r :: * -> *).
DeclStatement r =>
SVariable r -> r (Scope r) -> MSStatement r
varDec
  setDecDef :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> SValue CSharpCode
-> MSStatement CSharpCode
setDecDef = SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
DeclStatement r =>
SVariable r -> r (Scope r) -> SValue r -> MSStatement r
varDecDef
  listDec :: Integer
-> SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> MSStatement CSharpCode
listDec Integer
n SVariable CSharpCode
v CSharpCode (Scope CSharpCode)
scp = LensLike'
  (Zoomed (StateT ValueState Identity) (CSharpCode VarData))
  MethodState
  ValueState
-> State ValueState (CSharpCode VarData)
-> StateT MethodState Identity (CSharpCode VarData)
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) (CSharpCode VarData))
  MethodState
  ValueState
(ValueState -> Focusing Identity (CSharpCode VarData) ValueState)
-> MethodState
-> Focusing Identity (CSharpCode VarData) MethodState
Lens' MethodState ValueState
lensMStoVS State ValueState (CSharpCode VarData)
SVariable CSharpCode
v StateT MethodState Identity (CSharpCode VarData)
-> (CSharpCode VarData
    -> StateT MethodState Identity (CSharpCode (Doc, Terminator)))
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
forall a b.
StateT MethodState Identity a
-> (a -> StateT MethodState Identity b)
-> StateT MethodState Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (\CSharpCode VarData
v' -> (CSharpCode (Value CSharpCode) -> Doc)
-> SValue CSharpCode
-> SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(r (Value r) -> Doc)
-> SValue r -> SVariable r -> r (Scope r) -> MSStatement r
C.listDec (CSharpCode (Variable CSharpCode)
-> CSharpCode (Value CSharpCode) -> Doc
forall (r :: * -> *).
CommonRenderSym r =>
r (Variable r) -> r (Value r) -> Doc
R.listDec CSharpCode VarData
CSharpCode (Variable CSharpCode)
v') 
    (Integer -> SValue CSharpCode
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
n) SVariable CSharpCode
v CSharpCode (Scope CSharpCode)
scp)
  listDecDef :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SValue CSharpCode]
-> MSStatement CSharpCode
listDecDef = SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SValue CSharpCode]
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SVariable r -> r (Scope r) -> [SValue r] -> MSStatement r
CP.listDecDef
  arrayDec :: Integer
-> SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> MSStatement CSharpCode
arrayDec Integer
n = SValue CSharpCode
-> SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SValue r -> SVariable r -> r (Scope r) -> MSStatement r
CP.arrayDec (Integer -> SValue CSharpCode
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
n)
  arrayDecDef :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SValue CSharpCode]
-> MSStatement CSharpCode
arrayDecDef = SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SValue CSharpCode]
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SVariable r -> r (Scope r) -> [SValue r] -> MSStatement r
CP.arrayDecDef
  constDecDef :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> SValue CSharpCode
-> MSStatement CSharpCode
constDecDef = SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SVariable r -> r (Scope r) -> SValue r -> MSStatement r
CP.constDecDef
  funcDecDef :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SVariable CSharpCode]
-> MSBody CSharpCode
-> MSStatement CSharpCode
funcDecDef = SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SVariable CSharpCode]
-> MSBody CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SVariable r
-> r (Scope r) -> [SVariable r] -> MSBody r -> MSStatement r
csFuncDecDef

instance OODeclStatement CSharpCode where
  objDecDef :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> SValue CSharpCode
-> MSStatement CSharpCode
objDecDef = SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
DeclStatement r =>
SVariable r -> r (Scope r) -> SValue r -> MSStatement r
varDecDef
  objDecNew :: SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SValue CSharpCode]
-> MSStatement CSharpCode
objDecNew = SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SValue CSharpCode]
-> MSStatement CSharpCode
forall (r :: * -> *).
OORenderSym r =>
SVariable r -> r (Scope r) -> [SValue r] -> MSStatement r
G.objDecNew
  extObjDecNew :: String
-> SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SValue CSharpCode]
-> MSStatement CSharpCode
extObjDecNew = String
-> SVariable CSharpCode
-> CSharpCode (Scope CSharpCode)
-> [SValue CSharpCode]
-> MSStatement CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SVariable r -> r (Scope r) -> [SValue r] -> MSStatement r
C.extObjDecNew

instance IOStatement CSharpCode where
  print :: SValue CSharpCode -> MSStatement CSharpCode
print      = Bool
-> Maybe (SValue CSharpCode)
-> SValue CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
G.print Bool
False Maybe (VS (CSharpCode ValData))
Maybe (SValue CSharpCode)
forall a. Maybe a
Nothing SValue CSharpCode
forall (r :: * -> *). RenderValue r => SValue r
printFunc
  printLn :: SValue CSharpCode -> MSStatement CSharpCode
printLn    = Bool
-> Maybe (SValue CSharpCode)
-> SValue CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
G.print Bool
True  Maybe (VS (CSharpCode ValData))
Maybe (SValue CSharpCode)
forall a. Maybe a
Nothing SValue CSharpCode
forall (r :: * -> *). RenderValue r => SValue r
printLnFunc
  printStr :: String -> MSStatement CSharpCode
printStr   = Bool
-> Maybe (SValue CSharpCode)
-> SValue CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
G.print Bool
False Maybe (VS (CSharpCode ValData))
Maybe (SValue CSharpCode)
forall a. Maybe a
Nothing SValue CSharpCode
forall (r :: * -> *). RenderValue r => SValue r
printFunc   (SValue CSharpCode
 -> StateT MethodState Identity (CSharpCode (Doc, Terminator)))
-> (String -> SValue CSharpCode)
-> String
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> SValue CSharpCode
forall (r :: * -> *). Literal r => String -> SValue r
litString
  printStrLn :: String -> MSStatement CSharpCode
printStrLn = Bool
-> Maybe (SValue CSharpCode)
-> SValue CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
G.print Bool
True  Maybe (VS (CSharpCode ValData))
Maybe (SValue CSharpCode)
forall a. Maybe a
Nothing SValue CSharpCode
forall (r :: * -> *). RenderValue r => SValue r
printLnFunc (SValue CSharpCode
 -> StateT MethodState Identity (CSharpCode (Doc, Terminator)))
-> (String -> SValue CSharpCode)
-> String
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> SValue CSharpCode
forall (r :: * -> *). Literal r => String -> SValue r
litString

  printFile :: SValue CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
printFile SValue CSharpCode
f      = Bool
-> Maybe (SValue CSharpCode)
-> SValue CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
G.print Bool
False (VS (CSharpCode ValData) -> Maybe (VS (CSharpCode ValData))
forall a. a -> Maybe a
Just VS (CSharpCode ValData)
SValue CSharpCode
f) (SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). RenderValue r => SValue r -> SValue r
printFileFunc SValue CSharpCode
f)
  printFileLn :: SValue CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
printFileLn SValue CSharpCode
f    = Bool
-> Maybe (SValue CSharpCode)
-> SValue CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
G.print Bool
True  (VS (CSharpCode ValData) -> Maybe (VS (CSharpCode ValData))
forall a. a -> Maybe a
Just VS (CSharpCode ValData)
SValue CSharpCode
f) (SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). RenderValue r => SValue r -> SValue r
printFileLnFunc SValue CSharpCode
f)
  printFileStr :: SValue CSharpCode -> String -> MSStatement CSharpCode
printFileStr SValue CSharpCode
f   = Bool
-> Maybe (SValue CSharpCode)
-> SValue CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
G.print Bool
False (VS (CSharpCode ValData) -> Maybe (VS (CSharpCode ValData))
forall a. a -> Maybe a
Just VS (CSharpCode ValData)
SValue CSharpCode
f) (SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). RenderValue r => SValue r -> SValue r
printFileFunc SValue CSharpCode
f)   (VS (CSharpCode ValData)
 -> StateT MethodState Identity (CSharpCode (Doc, Terminator)))
-> (String -> VS (CSharpCode ValData))
-> String
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> VS (CSharpCode ValData)
String -> SValue CSharpCode
forall (r :: * -> *). Literal r => String -> SValue r
litString
  printFileStrLn :: SValue CSharpCode -> String -> MSStatement CSharpCode
printFileStrLn SValue CSharpCode
f = Bool
-> Maybe (SValue CSharpCode)
-> SValue CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
G.print Bool
True  (VS (CSharpCode ValData) -> Maybe (VS (CSharpCode ValData))
forall a. a -> Maybe a
Just VS (CSharpCode ValData)
SValue CSharpCode
f) (SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). RenderValue r => SValue r -> SValue r
printFileLnFunc SValue CSharpCode
f) (VS (CSharpCode ValData)
 -> StateT MethodState Identity (CSharpCode (Doc, Terminator)))
-> (String -> VS (CSharpCode ValData))
-> String
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> VS (CSharpCode ValData)
String -> SValue CSharpCode
forall (r :: * -> *). Literal r => String -> SValue r
litString

  getInput :: SVariable CSharpCode -> MSStatement CSharpCode
getInput SVariable CSharpCode
v = SVariable CSharpCode
v SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
&= VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
csInput ((CSharpCode (Variable CSharpCode) -> CSharpCode TypeData)
-> SVariable CSharpCode -> VS (CSharpCode TypeData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue CSharpCode (Variable CSharpCode) -> CSharpCode TypeData
CSharpCode (Variable CSharpCode) -> CSharpCode (Type CSharpCode)
forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable CSharpCode
v) SValue CSharpCode
forall (r :: * -> *). RenderValue r => SValue r
inputFunc
  discardInput :: MSStatement CSharpCode
discardInput = SValue CSharpCode -> MSStatement CSharpCode
csDiscardInput SValue CSharpCode
forall (r :: * -> *). RenderValue r => SValue r
inputFunc
  getFileInput :: SValue CSharpCode -> SVariable CSharpCode -> MSStatement CSharpCode
getFileInput SValue CSharpCode
f SVariable CSharpCode
v = SVariable CSharpCode
v SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
&= VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
csInput ((CSharpCode (Variable CSharpCode) -> CSharpCode TypeData)
-> SVariable CSharpCode -> VS (CSharpCode TypeData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue CSharpCode (Variable CSharpCode) -> CSharpCode TypeData
CSharpCode (Variable CSharpCode) -> CSharpCode (Type CSharpCode)
forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable CSharpCode
v) (SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). OORenderSym r => SValue r -> SValue r
csFileInput SValue CSharpCode
f)
  discardFileInput :: SValue CSharpCode -> MSStatement CSharpCode
discardFileInput SValue CSharpCode
f = SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *). StatementSym r => SValue r -> MSStatement r
valStmt (SValue CSharpCode -> MSStatement CSharpCode)
-> SValue CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). OORenderSym r => SValue r -> SValue r
csFileInput SValue CSharpCode
f

  openFileR :: SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
openFileR = (SValue CSharpCode -> VSType CSharpCode -> SValue CSharpCode)
-> SVariable CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(SValue r -> VSType r -> SValue r)
-> SVariable r -> SValue r -> MSStatement r
CP.openFileR SValue CSharpCode -> VSType CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
SValue r -> VSType r -> SValue r
csOpenFileR
  openFileW :: SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
openFileW = (SValue CSharpCode
 -> VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode)
-> SVariable CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(SValue r -> VSType r -> SValue r -> SValue r)
-> SVariable r -> SValue r -> MSStatement r
CP.openFileW SValue CSharpCode
-> VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
SValue r -> VSType r -> SValue r -> SValue r
csOpenFileWorA
  openFileA :: SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
openFileA = (SValue CSharpCode
 -> VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode)
-> SVariable CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(SValue r -> VSType r -> SValue r -> SValue r)
-> SVariable r -> SValue r -> MSStatement r
CP.openFileA SValue CSharpCode
-> VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OORenderSym r =>
SValue r -> VSType r -> SValue r -> SValue r
csOpenFileWorA
  closeFile :: SValue CSharpCode -> MSStatement CSharpCode
closeFile = String -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SValue r -> MSStatement r
G.closeFile String
csClose

  getFileInputLine :: SValue CSharpCode -> SVariable CSharpCode -> MSStatement CSharpCode
getFileInputLine = SValue CSharpCode -> SVariable CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
IOStatement r =>
SValue r -> SVariable r -> MSStatement r
getFileInput
  discardFileLine :: SValue CSharpCode -> MSStatement CSharpCode
discardFileLine = String -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SValue r -> MSStatement r
CP.discardFileLine String
csReadLine
  getFileInputAll :: SValue CSharpCode -> SVariable CSharpCode -> MSStatement CSharpCode
getFileInputAll SValue CSharpCode
f SVariable CSharpCode
v = SValue CSharpCode -> MSBody CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
ControlStatement r =>
SValue r -> MSBody r -> MSStatement r
while ((SValue CSharpCode
f SValue CSharpCode -> VSFunction CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OOFunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. Doc -> VSType CSharpCode -> VSFunction CSharpCode
forall (r :: * -> *).
RenderFunction r =>
Doc -> VSType r -> VSFunction r
funcFromData (Doc
dot Doc -> Doc -> Doc
<> String -> Doc
text String
csEOS) VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool) ?!)
    (MSStatement CSharpCode -> MSBody CSharpCode
forall (r :: * -> *). BodySym r => MSStatement r -> MSBody r
oneLiner (MSStatement CSharpCode -> MSBody CSharpCode)
-> MSStatement CSharpCode -> MSBody CSharpCode
forall a b. (a -> b) -> a -> b
$ SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *). StatementSym r => SValue r -> MSStatement r
valStmt (SValue CSharpCode -> MSStatement CSharpCode)
-> SValue CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ SValue CSharpCode -> SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). List r => SValue r -> SValue r -> SValue r
listAppend (SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable CSharpCode
v) (SValue CSharpCode -> SValue CSharpCode
forall (r :: * -> *). OORenderSym r => SValue r -> SValue r
csFileInput SValue CSharpCode
f))

instance StringStatement CSharpCode where
  stringSplit :: Char
-> SVariable CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
stringSplit Char
d SVariable CSharpCode
vnew SValue CSharpCode
s = SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
assign SVariable CSharpCode
vnew (SValue CSharpCode -> MSStatement CSharpCode)
-> SValue CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
forall (r :: * -> *). OOValueExpression r => PosCtorCall r
newObj (VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r -> VSType r
listType VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
string) 
    [SValue CSharpCode
s SValue CSharpCode -> VSFunction CSharpCode -> SValue CSharpCode
forall (r :: * -> *).
OOFunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. Char -> VSFunction CSharpCode
csSplitFunc Char
d]

  stringListVals :: [SVariable CSharpCode]
-> SValue CSharpCode -> MSStatement CSharpCode
stringListVals = [SVariable CSharpCode]
-> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
[SVariable r] -> SValue r -> MSStatement r
M.stringListVals
  stringListLists :: [SVariable CSharpCode]
-> SValue CSharpCode -> MSStatement CSharpCode
stringListLists = [SVariable CSharpCode]
-> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
[SVariable r] -> SValue r -> MSStatement r
M.stringListLists

instance FuncAppStatement CSharpCode where
  inOutCall :: InOutCall CSharpCode
inOutCall = (String
 -> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode)
-> InOutCall CSharpCode
csInOutCall String
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
forall (r :: * -> *). ValueExpression r => PosCall r
funcApp
  extInOutCall :: String -> InOutCall CSharpCode
extInOutCall String
m = (String
 -> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode)
-> InOutCall CSharpCode
csInOutCall (String
-> String
-> VSType CSharpCode
-> [SValue CSharpCode]
-> SValue CSharpCode
forall (r :: * -> *). ValueExpression r => String -> PosCall r
extFuncApp String
m)

instance OOFuncAppStatement CSharpCode where
  selfInOutCall :: InOutCall CSharpCode
selfInOutCall = (String
 -> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode)
-> InOutCall CSharpCode
csInOutCall String
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
forall (r :: * -> *). OOValueExpression r => PosCall r
selfFuncApp

instance CommentStatement CSharpCode where
  comment :: String -> MSStatement CSharpCode
comment = Doc -> String -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Doc -> String -> MSStatement r
G.comment Doc
commentStart

instance ControlStatement CSharpCode where
  break :: MSStatement CSharpCode
break =  Doc -> MSStatement CSharpCode
forall (r :: * -> *). CommonRenderSym r => Doc -> MSStatement r
mkStmt Doc
R.break
  continue :: MSStatement CSharpCode
continue =  Doc -> MSStatement CSharpCode
forall (r :: * -> *). CommonRenderSym r => Doc -> MSStatement r
mkStmt Doc
R.continue

  returnStmt :: SValue CSharpCode -> MSStatement CSharpCode
returnStmt = Terminator -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Terminator -> SValue r -> MSStatement r
G.returnStmt Terminator
Semi
  
  throw :: String -> MSStatement CSharpCode
throw String
msg = do
    (MethodState -> MethodState) -> StateT MethodState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (String -> MethodState -> MethodState
addLangImport String
csSystem)
    (CSharpCode (Value CSharpCode) -> Doc)
-> Terminator -> String -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(r (Value r) -> Doc) -> Terminator -> String -> MSStatement r
G.throw CSharpCode (Value CSharpCode) -> Doc
forall (r :: * -> *). CommonRenderSym r => r (Value r) -> Doc
csThrowDoc Terminator
Semi String
msg

  ifCond :: [(SValue CSharpCode, MSBody CSharpCode)]
-> MSBody CSharpCode -> MSStatement CSharpCode
ifCond = (Doc -> Doc)
-> Doc
-> OptionalSpace
-> Doc
-> Doc
-> Doc
-> [(SValue CSharpCode, MSBody CSharpCode)]
-> MSBody CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(Doc -> Doc)
-> Doc
-> OptionalSpace
-> Doc
-> Doc
-> Doc
-> [(SValue r, MSBody r)]
-> MSBody r
-> MSStatement r
G.ifCond Doc -> Doc
parens Doc
bodyStart OptionalSpace
G.defaultOptSpace Doc
elseIfLabel Doc
bodyEnd Doc
empty
  switch :: SValue CSharpCode
-> [(SValue CSharpCode, MSBody CSharpCode)]
-> MSBody CSharpCode
-> MSStatement CSharpCode
switch = (Doc -> Doc)
-> MSStatement CSharpCode
-> SValue CSharpCode
-> [(SValue CSharpCode, MSBody CSharpCode)]
-> MSBody CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(Doc -> Doc)
-> MSStatement r
-> SValue r
-> [(SValue r, MSBody r)]
-> MSBody r
-> MSStatement r
C.switch Doc -> Doc
parens MSStatement CSharpCode
forall (r :: * -> *). ControlStatement r => MSStatement r
break

  ifExists :: SValue CSharpCode
-> MSBody CSharpCode -> MSBody CSharpCode -> MSStatement CSharpCode
ifExists = SValue CSharpCode
-> MSBody CSharpCode -> MSBody CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SValue r -> MSBody r -> MSBody r -> MSStatement r
M.ifExists

  for :: MSStatement CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
-> MSBody CSharpCode
-> MSStatement CSharpCode
for = Doc
-> Doc
-> MSStatement CSharpCode
-> SValue CSharpCode
-> MSStatement CSharpCode
-> MSBody CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Doc
-> Doc
-> MSStatement r
-> SValue r
-> MSStatement r
-> MSBody r
-> MSStatement r
C.for Doc
bodyStart Doc
bodyEnd
  forRange :: SVariable CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> MSBody CSharpCode
-> MSStatement CSharpCode
forRange = SVariable CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> SValue CSharpCode
-> MSBody CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
SVariable r
-> SValue r -> SValue r -> SValue r -> MSBody r -> MSStatement r
M.forRange
  forEach :: SVariable CSharpCode
-> SValue CSharpCode -> MSBody CSharpCode -> MSStatement CSharpCode
forEach = Doc
-> Doc
-> Doc
-> Doc
-> SVariable CSharpCode
-> SValue CSharpCode
-> MSBody CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
Doc
-> Doc
-> Doc
-> Doc
-> SVariable r
-> SValue r
-> MSBody r
-> MSStatement r
CP.forEach Doc
bodyStart Doc
bodyEnd Doc
csForEach Doc
inLabel 
  while :: SValue CSharpCode -> MSBody CSharpCode -> MSStatement CSharpCode
while = (Doc -> Doc)
-> Doc
-> Doc
-> SValue CSharpCode
-> MSBody CSharpCode
-> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(Doc -> Doc) -> Doc -> Doc -> SValue r -> MSBody r -> MSStatement r
C.while Doc -> Doc
parens Doc
bodyStart Doc
bodyEnd

  tryCatch :: MSBody CSharpCode -> MSBody CSharpCode -> MSStatement CSharpCode
tryCatch = (CSharpCode (Body CSharpCode)
 -> CSharpCode (Body CSharpCode) -> Doc)
-> MSBody CSharpCode -> MSBody CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(r (Body r) -> r (Body r) -> Doc)
-> MSBody r -> MSBody r -> MSStatement r
G.tryCatch CSharpCode (Body CSharpCode) -> CSharpCode (Body CSharpCode) -> Doc
forall (r :: * -> *).
CommonRenderSym r =>
r (Body r) -> r (Body r) -> Doc
csTryCatch

  assert :: SValue CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
assert SValue CSharpCode
condition SValue CSharpCode
errorMessage = do
    (MethodState -> MethodState) -> StateT MethodState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (String -> MethodState -> MethodState
addLangImport String
csDiagnostics)
    CSharpCode ValData
cond <- LensLike'
  (Zoomed (StateT ValueState Identity) (CSharpCode ValData))
  MethodState
  ValueState
-> VS (CSharpCode ValData)
-> StateT MethodState Identity (CSharpCode ValData)
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) (CSharpCode ValData))
  MethodState
  ValueState
(ValueState -> Focusing Identity (CSharpCode ValData) ValueState)
-> MethodState
-> Focusing Identity (CSharpCode ValData) MethodState
Lens' MethodState ValueState
lensMStoVS VS (CSharpCode ValData)
SValue CSharpCode
condition
    CSharpCode ValData
errMsg <- LensLike'
  (Zoomed (StateT ValueState Identity) (CSharpCode ValData))
  MethodState
  ValueState
-> VS (CSharpCode ValData)
-> StateT MethodState Identity (CSharpCode ValData)
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) (CSharpCode ValData))
  MethodState
  ValueState
(ValueState -> Focusing Identity (CSharpCode ValData) ValueState)
-> MethodState
-> Focusing Identity (CSharpCode ValData) MethodState
Lens' MethodState ValueState
lensMStoVS VS (CSharpCode ValData)
SValue CSharpCode
errorMessage
    Doc -> MSStatement CSharpCode
forall (r :: * -> *). CommonRenderSym r => Doc -> MSStatement r
mkStmtNoEnd (CSharpCode (Value CSharpCode)
-> CSharpCode (Value CSharpCode) -> Doc
forall (r :: * -> *).
CommonRenderSym r =>
r (Value r) -> r (Value r) -> Doc
csAssert CSharpCode ValData
CSharpCode (Value CSharpCode)
cond CSharpCode ValData
CSharpCode (Value CSharpCode)
errMsg)

instance ObserverPattern CSharpCode where
  notifyObservers :: VSFunction CSharpCode
-> VSType CSharpCode -> MSStatement CSharpCode
notifyObservers = VSFunction CSharpCode
-> VSType CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
OORenderSym r =>
VSFunction r -> VSType r -> MSStatement r
M.notifyObservers

instance StrategyPattern CSharpCode where
  runStrategy :: String
-> [(String, MSBody CSharpCode)]
-> Maybe (SValue CSharpCode)
-> Maybe (SVariable CSharpCode)
-> MSBlock CSharpCode
runStrategy = String
-> [(String, MSBody CSharpCode)]
-> Maybe (SValue CSharpCode)
-> Maybe (SVariable CSharpCode)
-> State MethodState (CSharpCode Doc)
String
-> [(String, MSBody CSharpCode)]
-> Maybe (SValue CSharpCode)
-> Maybe (SVariable CSharpCode)
-> MSBlock CSharpCode
forall (r :: * -> *).
(CommonRenderSym r, Monad r) =>
String
-> [(String, MSBody r)]
-> Maybe (SValue r)
-> Maybe (SVariable r)
-> MS (r Doc)
M.runStrategy

instance VisibilitySym CSharpCode where
  type Visibility CSharpCode = Doc
  private :: CSharpCode (Visibility CSharpCode)
private = Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
R.private
  public :: CSharpCode (Visibility CSharpCode)
public = Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
R.public

instance RenderVisibility CSharpCode where
  visibilityFromData :: VisibilityTag -> Doc -> CSharpCode (Visibility CSharpCode)
visibilityFromData VisibilityTag
_ = Doc -> CSharpCode Doc
Doc -> CSharpCode (Visibility CSharpCode)
forall (r :: * -> *) a. Monad r => a -> r a
toCode
  
instance VisibilityElim CSharpCode where
  visibility :: CSharpCode (Visibility CSharpCode) -> Doc
visibility = CSharpCode Doc -> Doc
CSharpCode (Visibility CSharpCode) -> Doc
forall a. CSharpCode a -> a
unCSC

instance MethodTypeSym CSharpCode where
  type MethodType CSharpCode = TypeData
  mType :: VSType CSharpCode -> MSMthdType CSharpCode
mType = LensLike'
  (Zoomed (StateT ValueState Identity) (CSharpCode TypeData))
  MethodState
  ValueState
-> VS (CSharpCode TypeData)
-> StateT MethodState Identity (CSharpCode TypeData)
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) (CSharpCode TypeData))
  MethodState
  ValueState
(ValueState -> Focusing Identity (CSharpCode TypeData) ValueState)
-> MethodState
-> Focusing Identity (CSharpCode TypeData) MethodState
Lens' MethodState ValueState
lensMStoVS

instance OOMethodTypeSym CSharpCode where
  construct :: String -> MSMthdType CSharpCode
construct = String -> MS (CSharpCode (Type CSharpCode))
String -> MSMthdType CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
String -> MS (r (Type r))
G.construct

instance ParameterSym CSharpCode where
  type Parameter CSharpCode = ParamData
  param :: SVariable CSharpCode -> MSParameter CSharpCode
param = (CSharpCode (Variable CSharpCode) -> Doc)
-> SVariable CSharpCode -> MSParameter CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
(r (Variable r) -> Doc) -> SVariable r -> MSParameter r
G.param CSharpCode (Variable CSharpCode) -> Doc
forall (r :: * -> *). CommonRenderSym r => r (Variable r) -> Doc
R.param
  pointerParam :: SVariable CSharpCode -> MSParameter CSharpCode
pointerParam = SVariable CSharpCode -> MSParameter CSharpCode
forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param

instance RenderParam CSharpCode where
  paramFromData :: SVariable CSharpCode -> Doc -> MSParameter CSharpCode
paramFromData SVariable CSharpCode
v' Doc
d = do 
    CSharpCode VarData
v <- LensLike'
  (Zoomed (StateT ValueState Identity) (CSharpCode VarData))
  MethodState
  ValueState
-> State ValueState (CSharpCode VarData)
-> StateT MethodState Identity (CSharpCode VarData)
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) (CSharpCode VarData))
  MethodState
  ValueState
(ValueState -> Focusing Identity (CSharpCode VarData) ValueState)
-> MethodState
-> Focusing Identity (CSharpCode VarData) MethodState
Lens' MethodState ValueState
lensMStoVS State ValueState (CSharpCode VarData)
SVariable CSharpCode
v' 
    CSharpCode ParamData -> State MethodState (CSharpCode ParamData)
forall a s. a -> State s a
toState (CSharpCode ParamData -> State MethodState (CSharpCode ParamData))
-> CSharpCode ParamData -> State MethodState (CSharpCode ParamData)
forall a b. (a -> b) -> a -> b
$ (VarData -> Doc -> ParamData)
-> CSharpCode VarData -> CSharpCode Doc -> CSharpCode ParamData
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues VarData -> Doc -> ParamData
pd CSharpCode VarData
v (Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
d)

instance ParamElim CSharpCode where
  parameterName :: CSharpCode (Parameter CSharpCode) -> String
parameterName = CSharpCode VarData -> String
CSharpCode (Variable CSharpCode) -> String
forall (r :: * -> *). VariableElim r => r (Variable r) -> String
variableName (CSharpCode VarData -> String)
-> (CSharpCode ParamData -> CSharpCode VarData)
-> CSharpCode ParamData
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParamData -> VarData)
-> CSharpCode ParamData -> CSharpCode VarData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ParamData -> VarData
paramVar
  parameterType :: CSharpCode (Parameter CSharpCode) -> CSharpCode (Type CSharpCode)
parameterType = CSharpCode VarData -> CSharpCode TypeData
CSharpCode (Variable CSharpCode) -> CSharpCode (Type CSharpCode)
forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType (CSharpCode VarData -> CSharpCode TypeData)
-> (CSharpCode ParamData -> CSharpCode VarData)
-> CSharpCode ParamData
-> CSharpCode TypeData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParamData -> VarData)
-> CSharpCode ParamData -> CSharpCode VarData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ParamData -> VarData
paramVar
  parameter :: CSharpCode (Parameter CSharpCode) -> Doc
parameter = ParamData -> Doc
paramDoc (ParamData -> Doc)
-> (CSharpCode ParamData -> ParamData)
-> CSharpCode ParamData
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode ParamData -> ParamData
forall a. CSharpCode a -> a
unCSC

instance MethodSym CSharpCode where
  type Method CSharpCode = MethodData
  docMain :: MSBody CSharpCode -> SMethod CSharpCode
docMain = MSBody CSharpCode -> SMethod CSharpCode
forall (r :: * -> *). OORenderSym r => MSBody r -> SMethod r
CP.docMain
  function :: String
-> CSharpCode (Visibility CSharpCode)
-> VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
function = String
-> CSharpCode (Visibility CSharpCode)
-> VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String
-> r (Visibility r)
-> VSType r
-> [MSParameter r]
-> MSBody r
-> SMethod r
G.function
  mainFunction :: MSBody CSharpCode -> SMethod CSharpCode
mainFunction = VSType CSharpCode
-> String -> MSBody CSharpCode -> SMethod CSharpCode
forall (r :: * -> *).
OORenderSym r =>
VSType r -> String -> MSBody r -> SMethod r
CP.mainFunction VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
string String
csMain
  docFunc :: String
-> [String]
-> Maybe String
-> SMethod CSharpCode
-> SMethod CSharpCode
docFunc = String
-> [String]
-> Maybe String
-> SMethod CSharpCode
-> SMethod CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
String -> [String] -> Maybe String -> SMethod r -> SMethod r
CP.doxFunc

  inOutFunc :: String
-> CSharpCode (Visibility CSharpCode) -> InOutFunc CSharpCode
inOutFunc String
n CSharpCode (Visibility CSharpCode)
s = (VSType CSharpCode
 -> [MSParameter CSharpCode]
 -> MSBody CSharpCode
 -> SMethod CSharpCode)
-> InOutFunc CSharpCode
csInOut (String
-> CSharpCode (Visibility CSharpCode)
-> VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
forall (r :: * -> *).
MethodSym r =>
String
-> r (Visibility r)
-> VSType r
-> [MSParameter r]
-> MSBody r
-> SMethod r
function String
n CSharpCode (Visibility CSharpCode)
s)
  docInOutFunc :: String
-> CSharpCode (Visibility CSharpCode) -> DocInOutFunc CSharpCode
docInOutFunc String
n CSharpCode (Visibility CSharpCode)
s = InOutFunc CSharpCode -> DocInOutFunc CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
([SVariable r]
 -> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r)
-> String
-> [(String, SVariable r)]
-> [(String, SVariable r)]
-> [(String, SVariable r)]
-> MSBody r
-> SMethod r
CP.docInOutFunc (String
-> CSharpCode (Visibility CSharpCode) -> InOutFunc CSharpCode
forall (r :: * -> *).
MethodSym r =>
String -> r (Visibility r) -> InOutFunc r
inOutFunc String
n CSharpCode (Visibility CSharpCode)
s)

instance OOMethodSym CSharpCode where
  method :: String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
method = String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String
-> r (Visibility r)
-> r (Permanence r)
-> VSType r
-> [MSParameter r]
-> MSBody r
-> SMethod r
G.method
  getMethod :: SVariable CSharpCode -> SMethod CSharpCode
getMethod = SVariable CSharpCode -> SMethod CSharpCode
forall (r :: * -> *). OORenderSym r => SVariable r -> SMethod r
G.getMethod
  setMethod :: SVariable CSharpCode -> SMethod CSharpCode
setMethod = SVariable CSharpCode -> SMethod CSharpCode
forall (r :: * -> *). OORenderSym r => SVariable r -> SMethod r
G.setMethod
  constructor :: [MSParameter CSharpCode]
-> NamedArgs CSharpCode -> MSBody CSharpCode -> SMethod CSharpCode
constructor [MSParameter CSharpCode]
ps NamedArgs CSharpCode
is MSBody CSharpCode
b = MS String
getClassName MS String
-> (String -> StateT MethodState Identity (CSharpCode MethodData))
-> StateT MethodState Identity (CSharpCode MethodData)
forall a b.
StateT MethodState Identity a
-> (a -> StateT MethodState Identity b)
-> StateT MethodState Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (\String
n -> String
-> [MSParameter CSharpCode]
-> NamedArgs CSharpCode
-> MSBody CSharpCode
-> SMethod CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String
-> [MSParameter r] -> Initializers r -> MSBody r -> SMethod r
CP.constructor String
n [MSParameter CSharpCode]
ps NamedArgs CSharpCode
is MSBody CSharpCode
b)

  inOutMethod :: String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> InOutFunc CSharpCode
inOutMethod String
n CSharpCode (Visibility CSharpCode)
s CSharpCode (Permanence CSharpCode)
p = (VSType CSharpCode
 -> [MSParameter CSharpCode]
 -> MSBody CSharpCode
 -> SMethod CSharpCode)
-> InOutFunc CSharpCode
csInOut (String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
forall (r :: * -> *).
OOMethodSym r =>
String
-> r (Visibility r)
-> r (Permanence r)
-> VSType r
-> [MSParameter r]
-> MSBody r
-> SMethod r
method String
n CSharpCode (Visibility CSharpCode)
s CSharpCode (Permanence CSharpCode)
p)
  docInOutMethod :: String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> DocInOutFunc CSharpCode
docInOutMethod String
n CSharpCode (Visibility CSharpCode)
s CSharpCode (Permanence CSharpCode)
p = InOutFunc CSharpCode -> DocInOutFunc CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
([SVariable r]
 -> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r)
-> String
-> [(String, SVariable r)]
-> [(String, SVariable r)]
-> [(String, SVariable r)]
-> MSBody r
-> SMethod r
CP.docInOutFunc (String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> InOutFunc CSharpCode
forall (r :: * -> *).
OOMethodSym r =>
String -> r (Visibility r) -> r (Permanence r) -> InOutFunc r
inOutMethod String
n CSharpCode (Visibility CSharpCode)
s CSharpCode (Permanence CSharpCode)
p)

instance RenderMethod CSharpCode where
  commentedFunc :: MS (CSharpCode (BlockComment CSharpCode))
-> SMethod CSharpCode -> SMethod CSharpCode
commentedFunc MS (CSharpCode (BlockComment CSharpCode))
cmt SMethod CSharpCode
m = (CSharpCode MethodData
 -> CSharpCode (Doc -> Doc) -> CSharpCode MethodData)
-> StateT MethodState Identity (CSharpCode MethodData)
-> State MethodState (CSharpCode (Doc -> Doc))
-> StateT MethodState Identity (CSharpCode MethodData)
forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues ((MethodData -> (Doc -> Doc) -> MethodData)
-> CSharpCode MethodData
-> CSharpCode (Doc -> Doc)
-> CSharpCode MethodData
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues MethodData -> (Doc -> Doc) -> MethodData
updateMthd) StateT MethodState Identity (CSharpCode MethodData)
SMethod CSharpCode
m 
    ((CSharpCode Doc -> CSharpCode (Doc -> Doc))
-> State MethodState (CSharpCode Doc)
-> State MethodState (CSharpCode (Doc -> Doc))
forall a b s. (a -> b) -> State s a -> State s b
onStateValue ((Doc -> Doc -> Doc) -> CSharpCode Doc -> CSharpCode (Doc -> Doc)
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue Doc -> Doc -> Doc
R.commentedItem) State MethodState (CSharpCode Doc)
MS (CSharpCode (BlockComment CSharpCode))
cmt)
  
  mthdFromData :: VisibilityTag -> Doc -> SMethod CSharpCode
mthdFromData VisibilityTag
_ Doc
d = CSharpCode (Method CSharpCode) -> SMethod CSharpCode
forall a s. a -> State s a
toState (CSharpCode (Method CSharpCode) -> SMethod CSharpCode)
-> CSharpCode (Method CSharpCode) -> SMethod CSharpCode
forall a b. (a -> b) -> a -> b
$ MethodData -> CSharpCode MethodData
forall (r :: * -> *) a. Monad r => a -> r a
toCode (MethodData -> CSharpCode MethodData)
-> MethodData -> CSharpCode MethodData
forall a b. (a -> b) -> a -> b
$ Doc -> MethodData
mthd Doc
d

instance OORenderMethod CSharpCode where
  intMethod :: Bool
-> String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> MSMthdType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
intMethod Bool
m String
n CSharpCode (Visibility CSharpCode)
s CSharpCode (Permanence CSharpCode)
p MSMthdType CSharpCode
t [MSParameter CSharpCode]
ps MSBody CSharpCode
b = do
    (MethodState -> MethodState) -> StateT MethodState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (if Bool
m then MethodState -> MethodState
setCurrMain else MethodState -> MethodState
forall a. a -> a
id)
    CSharpCode TypeData
tp <- StateT MethodState Identity (CSharpCode TypeData)
MSMthdType CSharpCode
t
    [CSharpCode ParamData]
pms <- [State MethodState (CSharpCode ParamData)]
-> StateT MethodState Identity [CSharpCode 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 [State MethodState (CSharpCode ParamData)]
[MSParameter CSharpCode]
ps
    MethodData -> CSharpCode MethodData
forall (r :: * -> *) a. Monad r => a -> r a
toCode (MethodData -> CSharpCode MethodData)
-> (CSharpCode Doc -> MethodData)
-> CSharpCode Doc
-> CSharpCode MethodData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> MethodData
mthd (Doc -> MethodData)
-> (CSharpCode Doc -> Doc) -> CSharpCode Doc -> MethodData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> CSharpCode (Type CSharpCode)
-> [CSharpCode (Parameter CSharpCode)]
-> CSharpCode (Body CSharpCode)
-> Doc
forall (r :: * -> *).
OORenderSym r =>
String
-> r (Visibility r)
-> r (Permanence r)
-> r (Type r)
-> [r (Parameter r)]
-> r (Body r)
-> Doc
R.method String
n CSharpCode (Visibility CSharpCode)
s CSharpCode (Permanence CSharpCode)
p CSharpCode TypeData
CSharpCode (Type CSharpCode)
tp [CSharpCode ParamData]
[CSharpCode (Parameter CSharpCode)]
pms (CSharpCode Doc -> CSharpCode MethodData)
-> State MethodState (CSharpCode Doc)
-> StateT MethodState Identity (CSharpCode MethodData)
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
<$> State MethodState (CSharpCode Doc)
MSBody CSharpCode
b
  intFunc :: Bool
-> String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> MSMthdType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
intFunc = Bool
-> String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> MSMthdType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
forall (r :: * -> *).
OORenderSym r =>
Bool
-> String
-> r (Visibility r)
-> r (Permanence r)
-> MSMthdType r
-> [MSParameter r]
-> MSBody r
-> SMethod r
C.intFunc
  destructor :: [CSStateVar CSharpCode] -> SMethod CSharpCode
destructor [CSStateVar CSharpCode]
_ = String -> SMethod CSharpCode
forall a. HasCallStack => String -> a
error (String -> SMethod CSharpCode) -> String -> SMethod CSharpCode
forall a b. (a -> b) -> a -> b
$ String -> String
CP.destructorError String
csName
  
instance MethodElim CSharpCode where
  method :: CSharpCode (Method CSharpCode) -> Doc
method = MethodData -> Doc
mthdDoc (MethodData -> Doc)
-> (CSharpCode MethodData -> MethodData)
-> CSharpCode MethodData
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode MethodData -> MethodData
forall a. CSharpCode a -> a
unCSC

instance StateVarSym CSharpCode where
  type StateVar CSharpCode = Doc
  stateVar :: CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> SVariable CSharpCode
-> CSStateVar CSharpCode
stateVar = CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> SVariable CSharpCode
-> CS (CSharpCode Doc)
CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> SVariable CSharpCode
-> CSStateVar CSharpCode
forall (r :: * -> *).
(OORenderSym r, Monad r) =>
r (Visibility r) -> r (Permanence r) -> SVariable r -> CS (r Doc)
CP.stateVar
  stateVarDef :: CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> SVariable CSharpCode
-> SValue CSharpCode
-> CSStateVar CSharpCode
stateVarDef = CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> SVariable CSharpCode
-> SValue CSharpCode
-> CS (CSharpCode Doc)
CSharpCode (Visibility CSharpCode)
-> CSharpCode (Permanence CSharpCode)
-> SVariable CSharpCode
-> SValue CSharpCode
-> CSStateVar CSharpCode
forall (r :: * -> *).
(OORenderSym r, Monad r) =>
r (Visibility r)
-> r (Permanence r) -> SVariable r -> SValue r -> CS (r Doc)
CP.stateVarDef
  constVar :: CSharpCode (Visibility CSharpCode)
-> SVariable CSharpCode
-> SValue CSharpCode
-> CSStateVar CSharpCode
constVar = Doc
-> CSharpCode (Visibility CSharpCode)
-> SVariable CSharpCode
-> SValue CSharpCode
-> CS (CSharpCode Doc)
forall (r :: * -> *).
(CommonRenderSym r, Monad r) =>
Doc -> r (Visibility r) -> SVariable r -> SValue r -> CS (r Doc)
CP.constVar Doc
empty
  
instance StateVarElim CSharpCode where
  stateVar :: CSharpCode (StateVar CSharpCode) -> Doc
stateVar = CSharpCode Doc -> Doc
CSharpCode (StateVar CSharpCode) -> Doc
forall a. CSharpCode a -> a
unCSC

instance ClassSym CSharpCode where
  type Class CSharpCode = Doc
  buildClass :: Maybe String
-> [CSStateVar CSharpCode]
-> [SMethod CSharpCode]
-> [SMethod CSharpCode]
-> SClass CSharpCode
buildClass = Maybe String
-> [CSStateVar CSharpCode]
-> [SMethod CSharpCode]
-> [SMethod CSharpCode]
-> SClass CSharpCode
forall (r :: * -> *).
OORenderSym r =>
Maybe String
-> [CSStateVar r] -> [SMethod r] -> [SMethod r] -> SClass r
G.buildClass
  extraClass :: String
-> Maybe String
-> [CSStateVar CSharpCode]
-> [SMethod CSharpCode]
-> [SMethod CSharpCode]
-> SClass CSharpCode
extraClass = String
-> Maybe String
-> [CSStateVar CSharpCode]
-> [SMethod CSharpCode]
-> [SMethod CSharpCode]
-> SClass CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String
-> Maybe String
-> [CSStateVar r]
-> [SMethod r]
-> [SMethod r]
-> SClass r
CP.extraClass 
  implementingClass :: String
-> [String]
-> [CSStateVar CSharpCode]
-> [SMethod CSharpCode]
-> [SMethod CSharpCode]
-> SClass CSharpCode
implementingClass = String
-> [String]
-> [CSStateVar CSharpCode]
-> [SMethod CSharpCode]
-> [SMethod CSharpCode]
-> SClass CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String
-> [String]
-> [CSStateVar r]
-> [SMethod r]
-> [SMethod r]
-> SClass r
G.implementingClass

  docClass :: String -> SClass CSharpCode -> SClass CSharpCode
docClass = String -> SClass CSharpCode -> SClass CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String -> SClass r -> SClass r
CP.doxClass

instance RenderClass CSharpCode where
  intClass :: String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode Doc
-> [CSStateVar CSharpCode]
-> [SMethod CSharpCode]
-> [SMethod CSharpCode]
-> SClass CSharpCode
intClass = (String -> Doc -> Doc -> Doc -> Doc -> Doc)
-> String
-> CSharpCode (Visibility CSharpCode)
-> CSharpCode Doc
-> [CSStateVar CSharpCode]
-> [SMethod CSharpCode]
-> [SMethod CSharpCode]
-> CS (CSharpCode Doc)
forall (r :: * -> *).
(OORenderSym r, Monad r) =>
(String -> Doc -> Doc -> Doc -> Doc -> Doc)
-> String
-> r (Visibility r)
-> r Doc
-> [CSStateVar r]
-> [SMethod r]
-> [SMethod r]
-> CS (r Doc)
CP.intClass String -> Doc -> Doc -> Doc -> Doc -> Doc
R.class'

  inherit :: Maybe String -> CSharpCode Doc
inherit = Maybe String -> CSharpCode Doc
forall (r :: * -> *). Monad r => Maybe String -> r Doc
CP.inherit
  implements :: [String] -> CSharpCode Doc
implements = [String] -> CSharpCode Doc
forall (r :: * -> *). Monad r => [String] -> r Doc
CP.implements

  commentedClass :: CS (CSharpCode (BlockComment CSharpCode))
-> SClass CSharpCode -> SClass CSharpCode
commentedClass = CS (CSharpCode (BlockComment CSharpCode))
-> SClass CSharpCode -> CS (CSharpCode Doc)
CS (CSharpCode (BlockComment CSharpCode))
-> SClass CSharpCode -> SClass CSharpCode
forall (r :: * -> *).
(OORenderSym r, Monad r) =>
CS (r (BlockComment r)) -> SClass r -> CS (r Doc)
G.commentedClass
  
instance ClassElim CSharpCode where
  class' :: CSharpCode (Class CSharpCode) -> Doc
class' = CSharpCode Doc -> Doc
CSharpCode (Class CSharpCode) -> Doc
forall a. CSharpCode a -> a
unCSC

instance ModuleSym CSharpCode where
  type Module CSharpCode = ModData
  buildModule :: String
-> [String]
-> [SMethod CSharpCode]
-> [SClass CSharpCode]
-> FSModule CSharpCode
buildModule String
n = String
-> (String -> CSharpCode (Import CSharpCode))
-> [String]
-> [SMethod CSharpCode]
-> [SClass CSharpCode]
-> FSModule CSharpCode
forall (r :: * -> *).
OORenderSym r =>
String
-> (String -> r (Import r))
-> [String]
-> [SMethod r]
-> [SClass r]
-> FSModule r
CP.buildModule' String
n String -> CSharpCode (Import CSharpCode)
forall (r :: * -> *). ImportSym r => String -> r (Import r)
langImport
  
instance RenderMod CSharpCode where
  modFromData :: String -> FS Doc -> FSModule CSharpCode
modFromData String
n = String
-> (Doc -> CSharpCode (Module CSharpCode))
-> FS Doc
-> FSModule CSharpCode
forall (r :: * -> *).
String -> (Doc -> r (Module r)) -> FS Doc -> FSModule r
G.modFromData String
n (ModData -> CSharpCode ModData
forall (r :: * -> *) a. Monad r => a -> r a
toCode (ModData -> CSharpCode ModData)
-> (Doc -> ModData) -> Doc -> CSharpCode ModData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc -> ModData
md String
n)
  updateModuleDoc :: (Doc -> Doc)
-> CSharpCode (Module CSharpCode) -> CSharpCode (Module CSharpCode)
updateModuleDoc Doc -> Doc
f = (ModData -> ModData) -> CSharpCode ModData -> CSharpCode ModData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ((Doc -> Doc) -> ModData -> ModData
updateMod Doc -> Doc
f)
  
instance ModuleElim CSharpCode where
  module' :: CSharpCode (Module CSharpCode) -> Doc
module' = ModData -> Doc
modDoc (ModData -> Doc)
-> (CSharpCode ModData -> ModData) -> CSharpCode ModData -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CSharpCode ModData -> ModData
forall a. CSharpCode a -> a
unCSC

instance BlockCommentSym CSharpCode where
  type BlockComment CSharpCode = Doc
  blockComment :: [String] -> CSharpCode (BlockComment CSharpCode)
blockComment [String]
lns = Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode (Doc -> CSharpCode Doc) -> Doc -> CSharpCode Doc
forall a b. (a -> b) -> a -> b
$ [String] -> Doc -> Doc -> Doc
R.blockCmt [String]
lns Doc
blockCmtStart Doc
blockCmtEnd
  docComment :: forall a.
State a [String] -> State a (CSharpCode (BlockComment CSharpCode))
docComment = ([String] -> CSharpCode Doc)
-> StateT a Identity [String] -> State a (CSharpCode Doc)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue (\[String]
lns -> Doc -> CSharpCode Doc
forall (r :: * -> *) a. Monad r => a -> r a
toCode (Doc -> CSharpCode Doc) -> Doc -> CSharpCode Doc
forall a b. (a -> b) -> a -> b
$ [String] -> Doc -> Doc -> Doc
R.docCmt [String]
lns Doc
docCmtStart 
    Doc
blockCmtEnd)

instance BlockCommentElim CSharpCode where
  blockComment' :: CSharpCode (BlockComment CSharpCode) -> Doc
blockComment' = CSharpCode Doc -> Doc
CSharpCode (BlockComment CSharpCode) -> Doc
forall a. CSharpCode a -> a
unCSC

addSystemImport :: VS a -> VS a
addSystemImport :: forall a. VS a -> VS a
addSystemImport = StateT ValueState Identity ()
-> StateT ValueState Identity a -> StateT ValueState Identity a
forall a b.
StateT ValueState Identity a
-> StateT ValueState Identity b -> StateT ValueState Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
(>>) (StateT ValueState Identity ()
 -> StateT ValueState Identity a -> StateT ValueState Identity a)
-> StateT ValueState Identity ()
-> StateT ValueState Identity a
-> StateT ValueState Identity a
forall a b. (a -> b) -> a -> b
$ (ValueState -> ValueState) -> StateT ValueState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (String -> ValueState -> ValueState
addLangImportVS String
csSystem)

csName, csVersion :: String
csName :: String
csName = String
"C#"
csVersion :: String
csVersion = String
"6.0"

csImport :: Label -> Doc
csImport :: String -> Doc
csImport String
n = String -> Doc
text (String
"using " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
n) Doc -> Doc -> Doc
<> Doc
endStatement

csBoolType :: (CommonRenderSym r) => VSType r
csBoolType :: forall (r :: * -> *). CommonRenderSym r => VSType r
csBoolType = CodeType
-> String -> Doc -> StateT ValueState Identity (r (Type r))
forall (r :: * -> *).
RenderType r =>
CodeType -> String -> Doc -> VSType r
typeFromData CodeType
Boolean String
csBool (String -> Doc
text String
csBool)

csFuncType :: (CommonRenderSym r) => [VSType r] -> VSType r -> VSType r
csFuncType :: forall (r :: * -> *).
CommonRenderSym r =>
[VSType r] -> VSType r -> VSType r
csFuncType [VSType r]
ps VSType r
r = do
  [r (Type r)]
pts <- [VSType r] -> StateT ValueState Identity [r (Type r)]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence [VSType r]
ps
  r (Type r)
rt <- VSType r
r
  CodeType -> String -> Doc -> VSType r
forall (r :: * -> *).
RenderType r =>
CodeType -> String -> Doc -> VSType r
typeFromData ([CodeType] -> CodeType -> CodeType
Func ((r (Type r) -> CodeType) -> [r (Type r)] -> [CodeType]
forall a b. (a -> b) -> [a] -> [b]
map r (Type r) -> CodeType
forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType [r (Type r)]
pts) (r (Type r) -> CodeType
forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType r (Type r)
rt))
    (String
csFunc String -> String -> String
`containing` String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
listSep ((r (Type r) -> String) -> [r (Type r)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map r (Type r) -> String
forall (r :: * -> *). TypeElim r => r (Type r) -> String
getTypeString ([r (Type r)] -> [String]) -> [r (Type r)] -> [String]
forall a b. (a -> b) -> a -> b
$ [r (Type r)]
pts [r (Type r)] -> [r (Type r)] -> [r (Type r)]
forall a. [a] -> [a] -> [a]
++ [r (Type r)
rt]))
    (String -> Doc
text String
csFunc Doc -> Doc -> Doc
<> Doc -> Doc
angles (Doc -> [Doc] -> Doc
hicat Doc
listSep' ([Doc] -> Doc) -> [Doc] -> Doc
forall a b. (a -> b) -> a -> b
$ (r (Type r) -> Doc) -> [r (Type r)] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map r (Type r) -> Doc
forall (r :: * -> *). InternalTypeElim r => r (Type r) -> Doc
RC.type' ([r (Type r)] -> [Doc]) -> [r (Type r)] -> [Doc]
forall a b. (a -> b) -> a -> b
$ [r (Type r)]
pts [r (Type r)] -> [r (Type r)] -> [r (Type r)]
forall a. [a] -> [a] -> [a]
++ [r (Type r)
rt]))

csListSize, csForEach, csNamedArgSep, csLambdaSep :: Doc
csListSize :: Doc
csListSize = String -> Doc
text String
"Count"
csForEach :: Doc
csForEach = String -> Doc
text String
"foreach"
csNamedArgSep :: Doc
csNamedArgSep = Doc
colon Doc -> Doc -> Doc
<> Doc
space
csLambdaSep :: Doc
csLambdaSep = String -> Doc
text String
"=>"

csSystem, csConsole, csGeneric, csDiagnostics, csIO, csList, csSet, csInt, csFloat, csBool, 
  csChar, csParse, csReader, csWriter, csReadLine, csWrite, csWriteLine, 
  csIndex, csContains, csListAdd, csListAppend, csListRemove, csClose, csEOS, csSplit, csMain,
  csFunc, csUnionWith :: String
csSystem :: String
csSystem = String
"System"
csConsole :: String
csConsole = String
"Console"
csGeneric :: String
csGeneric = String -> String
csSysAccess (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ String
"Collections" String -> String -> String
`access` String
"Generic"
csDiagnostics :: String
csDiagnostics = String -> String
csSysAccess String
"Diagnostics"
csIO :: String
csIO = String -> String
csSysAccess String
"IO"
csList :: String
csList = String
"List"
csSet :: String
csSet = String
"HashSet"
csInt :: String
csInt = String
"Int32"
csFloat :: String
csFloat = String
"Single"
csBool :: String
csBool = String
"Boolean"
csChar :: String
csChar = String
"Char"
csParse :: String
csParse = String
"Parse"
csReader :: String
csReader = String
"StreamReader"
csWriter :: String
csWriter = String
"StreamWriter"
csReadLine :: String
csReadLine = String
"ReadLine"
csWrite :: String
csWrite = String
"Write"
csWriteLine :: String
csWriteLine = String
"WriteLine"
csIndex :: String
csIndex = String
"IndexOf"
csContains :: String
csContains = String
"Contains"
csListAdd :: String
csListAdd = String
"Insert"
csListAppend :: String
csListAppend = String
"Add"
csListRemove :: String
csListRemove = String
"Remove"
csClose :: String
csClose = String
"Close"
csEOS :: String
csEOS = String
"EndOfStream"
csSplit :: String
csSplit = String
"Split"
csMain :: String
csMain = String
"Main"
csFunc :: String
csFunc = String
"Func"
csUnionWith :: String
csUnionWith = String
"UnionWith"

csSysAccess :: String -> String
csSysAccess :: String -> String
csSysAccess = String -> String -> String
access String
csSystem

csUnaryMath :: (Monad r) => String -> VSOp r
csUnaryMath :: forall (r :: * -> *). Monad r => String -> VSOp r
csUnaryMath = VS (r OpData) -> VS (r OpData)
forall a. VS a -> VS a
addSystemImport (VS (r OpData) -> VS (r OpData))
-> (String -> VS (r OpData)) -> String -> VS (r OpData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> VS (r OpData)
forall (r :: * -> *). Monad r => String -> VSOp r
unOpPrec (String -> VS (r OpData))
-> (String -> String) -> String -> VS (r OpData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
mathFunc

csInfileType :: (CommonRenderSym r) => VSType r
csInfileType :: forall (r :: * -> *). CommonRenderSym r => VSType r
csInfileType = StateT
  ValueState Identity (StateT ValueState Identity (r (Type r)))
-> StateT ValueState Identity (r (Type r))
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (StateT
   ValueState Identity (StateT ValueState Identity (r (Type r)))
 -> StateT ValueState Identity (r (Type r)))
-> StateT
     ValueState Identity (StateT ValueState Identity (r (Type r)))
-> StateT ValueState Identity (r (Type r))
forall a b. (a -> b) -> a -> b
$ (ValueState -> ValueState)
-> StateT ValueState Identity (r (Type r))
-> StateT
     ValueState Identity (StateT ValueState Identity (r (Type r)))
forall s a. (s -> s) -> a -> State s a
modifyReturn (String -> ValueState -> ValueState
addLangImportVS String
csIO) (StateT ValueState Identity (r (Type r))
 -> StateT
      ValueState Identity (StateT ValueState Identity (r (Type r))))
-> StateT ValueState Identity (r (Type r))
-> StateT
     ValueState Identity (StateT ValueState Identity (r (Type r)))
forall a b. (a -> b) -> a -> b
$ 
  CodeType
-> String -> Doc -> StateT ValueState Identity (r (Type r))
forall (r :: * -> *).
RenderType r =>
CodeType -> String -> Doc -> VSType r
typeFromData CodeType
InFile String
csReader (String -> Doc
text String
csReader)

csOutfileType :: (CommonRenderSym r) => VSType r
csOutfileType :: forall (r :: * -> *). CommonRenderSym r => VSType r
csOutfileType = StateT
  ValueState Identity (StateT ValueState Identity (r (Type r)))
-> StateT ValueState Identity (r (Type r))
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (StateT
   ValueState Identity (StateT ValueState Identity (r (Type r)))
 -> StateT ValueState Identity (r (Type r)))
-> StateT
     ValueState Identity (StateT ValueState Identity (r (Type r)))
-> StateT ValueState Identity (r (Type r))
forall a b. (a -> b) -> a -> b
$ (ValueState -> ValueState)
-> StateT ValueState Identity (r (Type r))
-> StateT
     ValueState Identity (StateT ValueState Identity (r (Type r)))
forall s a. (s -> s) -> a -> State s a
modifyReturn (String -> ValueState -> ValueState
addLangImportVS String
csIO) (StateT ValueState Identity (r (Type r))
 -> StateT
      ValueState Identity (StateT ValueState Identity (r (Type r))))
-> StateT ValueState Identity (r (Type r))
-> StateT
     ValueState Identity (StateT ValueState Identity (r (Type r)))
forall a b. (a -> b) -> a -> b
$ 
  CodeType
-> String -> Doc -> StateT ValueState Identity (r (Type r))
forall (r :: * -> *).
RenderType r =>
CodeType -> String -> Doc -> VSType r
typeFromData CodeType
OutFile String
csWriter (String -> Doc
text String
csWriter)

csLitList :: (CommonRenderSym r) => (VSType r -> VSType r) -> VSType r -> [SValue r] 
  -> SValue r
csLitList :: forall (r :: * -> *).
CommonRenderSym r =>
(VSType r -> VSType r) -> VSType r -> [SValue r] -> SValue r
csLitList VSType r -> VSType r
f VSType r
t' [SValue r]
es' = do 
  [r (Value r)]
es <- [SValue r] -> StateT ValueState Identity [r (Value r)]
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 r]
es' 
  r (Type r)
lt <- VSType r -> VSType r
f VSType r
t'
  r (Type r) -> Doc -> SValue r
forall (r :: * -> *).
CommonRenderSym r =>
r (Type r) -> Doc -> SValue r
mkVal r (Type r)
lt (Doc
new' Doc -> Doc -> Doc
<+> r (Type r) -> Doc
forall (r :: * -> *). InternalTypeElim r => r (Type r) -> Doc
RC.type' r (Type r)
lt
    Doc -> Doc -> Doc
<+> Doc -> Doc
braces ([r (Value r)] -> Doc
forall (r :: * -> *). CommonRenderSym r => [r (Value r)] -> Doc
valueList [r (Value r)]
es))

csLambda :: (CommonRenderSym r) => [r (Variable r)] -> r (Value r) -> Doc
csLambda :: forall (r :: * -> *).
CommonRenderSym r =>
[r (Variable r)] -> r (Value r) -> Doc
csLambda [r (Variable r)]
ps r (Value r)
ex = Doc -> Doc
parens ([r (Variable r)] -> Doc
forall (r :: * -> *). CommonRenderSym r => [r (Variable r)] -> Doc
variableList [r (Variable r)]
ps) Doc -> Doc -> Doc
<+> Doc
csLambdaSep Doc -> Doc -> Doc
<+> r (Value r) -> Doc
forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value r (Value r)
ex

csReadLineFunc :: SValue CSharpCode
csReadLineFunc :: SValue CSharpCode
csReadLineFunc = String
-> String
-> VSType CSharpCode
-> [SValue CSharpCode]
-> SValue CSharpCode
forall (r :: * -> *). ValueExpression r => String -> PosCall r
extFuncApp String
csConsole String
csReadLine VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
string []

csIntParse :: SValue CSharpCode -> SValue CSharpCode
csIntParse :: SValue CSharpCode -> SValue CSharpCode
csIntParse SValue CSharpCode
v = String
-> String
-> VSType CSharpCode
-> [SValue CSharpCode]
-> SValue CSharpCode
forall (r :: * -> *). ValueExpression r => String -> PosCall r
extFuncApp String
csInt String
csParse VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
int [SValue CSharpCode
v] 

csFloatParse :: SValue CSharpCode -> SValue CSharpCode
csFloatParse :: SValue CSharpCode -> SValue CSharpCode
csFloatParse SValue CSharpCode
v = String
-> String
-> VSType CSharpCode
-> [SValue CSharpCode]
-> SValue CSharpCode
forall (r :: * -> *). ValueExpression r => String -> PosCall r
extFuncApp String
csFloat String
csParse VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
float [SValue CSharpCode
v] 

csDblParse :: SValue CSharpCode -> SValue CSharpCode
csDblParse :: SValue CSharpCode -> SValue CSharpCode
csDblParse SValue CSharpCode
v = String
-> String
-> VSType CSharpCode
-> [SValue CSharpCode]
-> SValue CSharpCode
forall (r :: * -> *). ValueExpression r => String -> PosCall r
extFuncApp String
CP.doubleRender String
csParse VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
double [SValue CSharpCode
v] 

csBoolParse :: SValue CSharpCode -> SValue CSharpCode
csBoolParse :: SValue CSharpCode -> SValue CSharpCode
csBoolParse SValue CSharpCode
v = String
-> String
-> VSType CSharpCode
-> [SValue CSharpCode]
-> SValue CSharpCode
forall (r :: * -> *). ValueExpression r => String -> PosCall r
extFuncApp String
csBool String
csParse VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
bool [SValue CSharpCode
v] 

csCharParse :: SValue CSharpCode -> SValue CSharpCode
csCharParse :: SValue CSharpCode -> SValue CSharpCode
csCharParse SValue CSharpCode
v = String
-> String
-> VSType CSharpCode
-> [SValue CSharpCode]
-> SValue CSharpCode
forall (r :: * -> *). ValueExpression r => String -> PosCall r
extFuncApp String
csChar String
csParse VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
char [SValue CSharpCode
v] 

csSplitFunc :: Char -> VSFunction CSharpCode
csSplitFunc :: Char -> VSFunction CSharpCode
csSplitFunc Char
d = String
-> VSType CSharpCode
-> [SValue CSharpCode]
-> VSFunction CSharpCode
forall (r :: * -> *).
OOFunctionSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
func String
csSplit (VSType CSharpCode -> VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r -> VSType r
listType VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
string) [Char -> SValue CSharpCode
forall (r :: * -> *). Literal r => Char -> SValue r
litChar Char
d]

csCast :: VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
csCast :: VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
csCast = StateT ValueState Identity (VS (CSharpCode ValData))
-> VS (CSharpCode ValData)
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (StateT ValueState Identity (VS (CSharpCode ValData))
 -> VS (CSharpCode ValData))
-> (VS (CSharpCode TypeData)
    -> VS (CSharpCode ValData)
    -> StateT ValueState Identity (VS (CSharpCode ValData)))
-> VS (CSharpCode TypeData)
-> VS (CSharpCode ValData)
-> VS (CSharpCode ValData)
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: (CSharpCode TypeData
 -> CSharpCode ValData -> VS (CSharpCode ValData))
-> VS (CSharpCode TypeData)
-> VS (CSharpCode ValData)
-> StateT ValueState Identity (VS (CSharpCode ValData))
forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues (\CSharpCode TypeData
t CSharpCode ValData
v -> CodeType
-> CodeType
-> CSharpCode TypeData
-> CSharpCode ValData
-> VS (CSharpCode ValData)
csCast' (CSharpCode (Type CSharpCode) -> CodeType
forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType CSharpCode TypeData
CSharpCode (Type CSharpCode)
t) (CSharpCode (Type CSharpCode) -> CodeType
forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType (CSharpCode (Type CSharpCode) -> CodeType)
-> CSharpCode (Type CSharpCode) -> CodeType
forall a b. (a -> b) -> a -> b
$ 
  CSharpCode (Value CSharpCode) -> CSharpCode (Type CSharpCode)
forall (r :: * -> *). ValueSym r => r (Value r) -> r (Type r)
valueType CSharpCode ValData
CSharpCode (Value CSharpCode)
v) CSharpCode TypeData
t CSharpCode ValData
v)
  where csCast' :: CodeType
-> CodeType
-> CSharpCode TypeData
-> CSharpCode ValData
-> SValue CSharpCode
csCast' CodeType
Double CodeType
String CSharpCode TypeData
_ CSharpCode ValData
v = SValue CSharpCode -> SValue CSharpCode
csDblParse (CSharpCode ValData -> VS (CSharpCode ValData)
forall a s. a -> State s a
toState CSharpCode ValData
v)
        csCast' CodeType
Float CodeType
String CSharpCode TypeData
_ CSharpCode ValData
v = SValue CSharpCode -> SValue CSharpCode
csFloatParse (CSharpCode ValData -> VS (CSharpCode ValData)
forall a s. a -> State s a
toState CSharpCode ValData
v)
        csCast' CodeType
_ CodeType
_ CSharpCode TypeData
t CSharpCode ValData
v = VSType CSharpCode -> Doc -> SValue CSharpCode
forall (r :: * -> *).
CommonRenderSym r =>
VSType r -> Doc -> SValue r
mkStateVal (CSharpCode TypeData -> VS (CSharpCode TypeData)
forall a s. a -> State s a
toState CSharpCode TypeData
t) (Doc -> Doc -> Doc
R.castObj (Doc -> Doc
R.cast 
          (CSharpCode (Type CSharpCode) -> Doc
forall (r :: * -> *). InternalTypeElim r => r (Type r) -> Doc
RC.type' CSharpCode TypeData
CSharpCode (Type CSharpCode)
t)) (CSharpCode (Value CSharpCode) -> Doc
forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value CSharpCode ValData
CSharpCode (Value CSharpCode)
v))

-- This implementation generates a statement lambda to define the function. 
-- C# 7 supports local functions, which would be a cleaner way to implement
-- this, but the mcs compiler used in our Travis builds does not yet support 
-- all features of C# 7, so we cannot generate local functions.
-- If support for local functions is added to mcs in the future, this
-- should be re-written to generate a local function.
csFuncDecDef :: (CommonRenderSym r) => SVariable r -> r (Scope r) ->
  [SVariable r] -> MSBody r -> MSStatement r
csFuncDecDef :: forall (r :: * -> *).
CommonRenderSym r =>
SVariable r
-> r (Scope r) -> [SVariable r] -> MSBody r -> MSStatement r
csFuncDecDef SVariable r
v r (Scope r)
scp [SVariable r]
ps MSBody r
bod = do
  r (Variable r)
vr <- LensLike'
  (Zoomed (StateT ValueState Identity) (r (Variable r)))
  MethodState
  ValueState
-> SVariable r -> StateT MethodState Identity (r (Variable r))
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) (r (Variable r)))
  MethodState
  ValueState
(ValueState -> Focusing Identity (r (Variable r)) ValueState)
-> MethodState -> Focusing Identity (r (Variable r)) MethodState
Lens' MethodState ValueState
lensMStoVS SVariable r
v
  (MethodState -> MethodState) -> StateT MethodState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify ((MethodState -> MethodState) -> StateT MethodState Identity ())
-> (MethodState -> MethodState) -> StateT MethodState Identity ()
forall a b. (a -> b) -> a -> b
$ String -> MethodState -> MethodState
useVarName (String -> MethodState -> MethodState)
-> String -> MethodState -> MethodState
forall a b. (a -> b) -> a -> b
$ r (Variable r) -> String
forall (r :: * -> *). VariableElim r => r (Variable r) -> String
variableName r (Variable r)
vr
  (MethodState -> MethodState) -> StateT MethodState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify ((MethodState -> MethodState) -> StateT MethodState Identity ())
-> (MethodState -> MethodState) -> StateT MethodState Identity ()
forall a b. (a -> b) -> a -> b
$ String -> ScopeData -> MethodState -> MethodState
setVarScope (r (Variable r) -> String
forall (r :: * -> *). VariableElim r => r (Variable r) -> String
variableName r (Variable r)
vr) (r (Scope r) -> ScopeData
forall (r :: * -> *). ScopeElim r => r (Scope r) -> ScopeData
scopeData r (Scope r)
scp)
  [r (Variable r)]
pms <- (SVariable r -> StateT MethodState Identity (r (Variable r)))
-> [SVariable r] -> StateT MethodState Identity [r (Variable r)]
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) (r (Variable r)))
  MethodState
  ValueState
-> SVariable r -> StateT MethodState Identity (r (Variable r))
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) (r (Variable r)))
  MethodState
  ValueState
(ValueState -> Focusing Identity (r (Variable r)) ValueState)
-> MethodState -> Focusing Identity (r (Variable r)) MethodState
Lens' MethodState ValueState
lensMStoVS) [SVariable r]
ps
  r (Type r)
t <- LensLike'
  (Zoomed (StateT ValueState Identity) (r (Type r)))
  MethodState
  ValueState
-> StateT ValueState Identity (r (Type r))
-> StateT MethodState Identity (r (Type r))
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) (r (Type r)))
  MethodState
  ValueState
(ValueState -> Focusing Identity (r (Type r)) ValueState)
-> MethodState -> Focusing Identity (r (Type r)) MethodState
Lens' MethodState ValueState
lensMStoVS (StateT ValueState Identity (r (Type r))
 -> StateT MethodState Identity (r (Type r)))
-> StateT ValueState Identity (r (Type r))
-> StateT MethodState Identity (r (Type r))
forall a b. (a -> b) -> a -> b
$ [StateT ValueState Identity (r (Type r))]
-> StateT ValueState Identity (r (Type r))
-> StateT ValueState Identity (r (Type r))
forall (r :: * -> *).
TypeSym r =>
[VSType r] -> VSType r -> VSType r
funcType ((r (Variable r) -> StateT ValueState Identity (r (Type r)))
-> [r (Variable r)] -> [StateT ValueState Identity (r (Type r))]
forall a b. (a -> b) -> [a] -> [b]
map (r (Type r) -> StateT ValueState Identity (r (Type r))
forall a. a -> StateT ValueState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (r (Type r) -> StateT ValueState Identity (r (Type r)))
-> (r (Variable r) -> r (Type r))
-> r (Variable r)
-> StateT ValueState Identity (r (Type r))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r (Variable r) -> r (Type r)
forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType) [r (Variable r)]
pms) 
    (r (Type r) -> StateT ValueState Identity (r (Type r))
forall a. a -> StateT ValueState Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (r (Type r) -> StateT ValueState Identity (r (Type r)))
-> r (Type r) -> StateT ValueState Identity (r (Type r))
forall a b. (a -> b) -> a -> b
$ r (Variable r) -> r (Type r)
forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType r (Variable r)
vr)
  r (Body r)
b <- MSBody r
bod
  (MethodState -> MethodState) -> StateT MethodState Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (String -> MethodState -> MethodState
addLangImport String
csSystem)
  Doc -> MSStatement r
forall (r :: * -> *). CommonRenderSym r => Doc -> MSStatement r
mkStmt (Doc -> MSStatement r) -> Doc -> MSStatement r
forall a b. (a -> b) -> a -> b
$ r (Type r) -> Doc
forall (r :: * -> *). InternalTypeElim r => r (Type r) -> Doc
RC.type' r (Type r)
t Doc -> Doc -> Doc
<+> String -> Doc
text (r (Variable r) -> String
forall (r :: * -> *). VariableElim r => r (Variable r) -> String
variableName r (Variable r)
vr) Doc -> Doc -> Doc
<+> Doc
equals Doc -> Doc -> Doc
<+>
    Doc -> Doc
parens ([r (Variable r)] -> Doc
forall (r :: * -> *). CommonRenderSym r => [r (Variable r)] -> Doc
variableList [r (Variable r)]
pms) Doc -> Doc -> Doc
<+> Doc
csLambdaSep Doc -> Doc -> Doc
<+> Doc
bodyStart Doc -> Doc -> Doc
$$ 
    Doc -> Doc
indent (r (Body r) -> Doc
forall (r :: * -> *). BodyElim r => r (Body r) -> Doc
RC.body r (Body r)
b) Doc -> Doc -> Doc
$$ Doc
bodyEnd 

csThrowDoc :: (CommonRenderSym r) => r (Value r) -> Doc
csThrowDoc :: forall (r :: * -> *). CommonRenderSym r => r (Value r) -> Doc
csThrowDoc r (Value r)
errMsg = Doc
throwLabel Doc -> Doc -> Doc
<+> Doc
new' Doc -> Doc -> Doc
<+> Doc
exceptionObj' Doc -> Doc -> Doc
<> 
  Doc -> Doc
parens (r (Value r) -> Doc
forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value r (Value r)
errMsg)

csTryCatch :: (CommonRenderSym r) => r (Body r) -> r (Body r) -> Doc
csTryCatch :: forall (r :: * -> *).
CommonRenderSym r =>
r (Body r) -> r (Body r) -> Doc
csTryCatch r (Body r)
tb r (Body r)
cb = [Doc] -> Doc
vcat [
  Doc
tryLabel Doc -> Doc -> Doc
<+> Doc
lbrace,
  Doc -> Doc
indent (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ r (Body r) -> Doc
forall (r :: * -> *). BodyElim r => r (Body r) -> Doc
RC.body r (Body r)
tb,
  Doc
rbrace Doc -> Doc -> Doc
<+> Doc
catchLabel Doc -> Doc -> Doc
<+> 
    Doc
lbrace,
  Doc -> Doc
indent (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ r (Body r) -> Doc
forall (r :: * -> *). BodyElim r => r (Body r) -> Doc
RC.body r (Body r)
cb,
  Doc
rbrace]

csAssert :: (CommonRenderSym r) => r (Value r) -> r (Value r) -> Doc
csAssert :: forall (r :: * -> *).
CommonRenderSym r =>
r (Value r) -> r (Value r) -> Doc
csAssert r (Value r)
condition r (Value r)
errorMessage = [Doc] -> Doc
vcat [
  String -> Doc
text String
"Debug.Assert(" Doc -> Doc -> Doc
<+> r (Value r) -> Doc
forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value r (Value r)
condition Doc -> Doc -> Doc
<+> String -> Doc
text String
"," Doc -> Doc -> Doc
<+> r (Value r) -> Doc
forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value r (Value r)
errorMessage Doc -> Doc -> Doc
<> String -> Doc
text String
")" Doc -> Doc -> Doc
<> Doc
semi
  ]

csDiscardInput :: SValue CSharpCode -> MSStatement CSharpCode
csDiscardInput :: SValue CSharpCode -> MSStatement CSharpCode
csDiscardInput = SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *). StatementSym r => SValue r -> MSStatement r
valStmt

csFileInput :: (OORenderSym r) => SValue r -> SValue r
csFileInput :: forall (r :: * -> *). OORenderSym r => SValue r -> SValue r
csFileInput SValue r
f = VSType r -> SValue r -> String -> SValue r
forall (r :: * -> *).
InternalValueExp r =>
VSType r -> SValue r -> String -> SValue r
objMethodCallNoParams VSType r
forall (r :: * -> *). TypeSym r => VSType r
string SValue r
f String
csReadLine 

csInput :: VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
csInput :: VSType CSharpCode -> SValue CSharpCode -> SValue CSharpCode
csInput VSType CSharpCode
tp SValue CSharpCode
inFn = do
  CSharpCode TypeData
t <- VS (CSharpCode TypeData)
VSType CSharpCode
tp
  CodeType -> VS (CSharpCode ValData) -> VS (CSharpCode ValData)
forall {a}. CodeType -> VS a -> VS a
csInputImport (CSharpCode (Type CSharpCode) -> CodeType
forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType CSharpCode TypeData
CSharpCode (Type CSharpCode)
t) (CodeType -> VS (CSharpCode ValData) -> VS (CSharpCode ValData)
csInput' (CSharpCode (Type CSharpCode) -> CodeType
forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType CSharpCode TypeData
CSharpCode (Type CSharpCode)
t) VS (CSharpCode ValData)
SValue CSharpCode
inFn)
  where csInput' :: CodeType -> SValue CSharpCode -> SValue CSharpCode
csInput' CodeType
Integer = SValue CSharpCode -> SValue CSharpCode
csIntParse
        csInput' CodeType
Float = SValue CSharpCode -> SValue CSharpCode
csFloatParse
        csInput' CodeType
Double = SValue CSharpCode -> SValue CSharpCode
csDblParse
        csInput' CodeType
Boolean = SValue CSharpCode -> SValue CSharpCode
csBoolParse
        csInput' CodeType
String = VS (CSharpCode ValData) -> VS (CSharpCode ValData)
SValue CSharpCode -> SValue CSharpCode
forall a. a -> a
id
        csInput' CodeType
Char = SValue CSharpCode -> SValue CSharpCode
csCharParse
        csInput' CodeType
_ = String -> VS (CSharpCode ValData) -> VS (CSharpCode ValData)
forall a. HasCallStack => String -> a
error String
"Attempt to read value of unreadable type"
        csInputImport :: CodeType -> VS a -> VS a
csInputImport CodeType
t = if CodeType
t CodeType -> [CodeType] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [CodeType
Integer, CodeType
Float, CodeType
Double, CodeType
Boolean, CodeType
Char] 
          then VS a -> VS a
forall a. VS a -> VS a
addSystemImport else VS a -> VS a
forall a. a -> a
id

csOpenFileR :: (OORenderSym r) => SValue r -> VSType r -> SValue r
csOpenFileR :: forall (r :: * -> *).
OORenderSym r =>
SValue r -> VSType r -> SValue r
csOpenFileR SValue r
n VSType r
r = PosCtorCall r
forall (r :: * -> *). OOValueExpression r => PosCtorCall r
newObj VSType r
r [SValue r
n]

csOpenFileWorA :: (OORenderSym r) => SValue r -> VSType r -> SValue r -> SValue r
csOpenFileWorA :: forall (r :: * -> *).
OORenderSym r =>
SValue r -> VSType r -> SValue r -> SValue r
csOpenFileWorA SValue r
n VSType r
w SValue r
a = PosCtorCall r
forall (r :: * -> *). OOValueExpression r => PosCtorCall r
newObj VSType r
w [SValue r
n, SValue r
a] 

csRef :: Doc -> Doc
csRef :: Doc -> Doc
csRef Doc
p = String -> Doc
text String
"ref" Doc -> Doc -> Doc
<+> Doc
p

csOut :: Doc -> Doc
csOut :: Doc -> Doc
csOut Doc
p = String -> Doc
text String
"out" Doc -> Doc -> Doc
<+> Doc
p

csInOutCall :: (Label -> VSType CSharpCode -> [SValue CSharpCode] -> 
  SValue CSharpCode) -> Label -> [SValue CSharpCode] -> [SVariable CSharpCode] 
  -> [SVariable CSharpCode] -> MSStatement CSharpCode
csInOutCall :: (String
 -> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode)
-> InOutCall CSharpCode
csInOutCall String
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
f String
n [SValue CSharpCode]
ins [SVariable CSharpCode
out] [] = SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
assign SVariable CSharpCode
out (SValue CSharpCode -> MSStatement CSharpCode)
-> SValue CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ String
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
f String
n ((CSharpCode (Variable CSharpCode) -> CSharpCode TypeData)
-> SVariable CSharpCode -> VS (CSharpCode TypeData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue CSharpCode (Variable CSharpCode) -> CSharpCode TypeData
CSharpCode (Variable CSharpCode) -> CSharpCode (Type CSharpCode)
forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable CSharpCode
out) 
  [SValue CSharpCode]
ins
csInOutCall String
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
f String
n [SValue CSharpCode]
ins [] [SVariable CSharpCode
out] = SVariable CSharpCode -> SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
assign SVariable CSharpCode
out (SValue CSharpCode -> MSStatement CSharpCode)
-> SValue CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ String
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
f String
n ((CSharpCode (Variable CSharpCode) -> CSharpCode TypeData)
-> SVariable CSharpCode -> VS (CSharpCode TypeData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue CSharpCode (Variable CSharpCode) -> CSharpCode TypeData
CSharpCode (Variable CSharpCode) -> CSharpCode (Type CSharpCode)
forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable CSharpCode
out) 
  (SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable CSharpCode
out VS (CSharpCode ValData)
-> [VS (CSharpCode ValData)] -> [VS (CSharpCode ValData)]
forall a. a -> [a] -> [a]
: [VS (CSharpCode ValData)]
[SValue CSharpCode]
ins)
csInOutCall String
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
f String
n [SValue CSharpCode]
ins [SVariable CSharpCode]
outs [SVariable CSharpCode]
both = SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *). StatementSym r => SValue r -> MSStatement r
valStmt (SValue CSharpCode -> MSStatement CSharpCode)
-> SValue CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ String
-> VSType CSharpCode -> [SValue CSharpCode] -> SValue CSharpCode
f String
n VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
void ((State ValueState (CSharpCode VarData) -> VS (CSharpCode ValData))
-> [State ValueState (CSharpCode VarData)]
-> [VS (CSharpCode ValData)]
forall a b. (a -> b) -> [a] -> [b]
map ((CSharpCode ValData -> CSharpCode ValData)
-> VS (CSharpCode ValData) -> VS (CSharpCode ValData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue 
  ((ValData -> ValData) -> CSharpCode ValData -> CSharpCode ValData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ((Doc -> Doc) -> ValData -> ValData
updateValDoc Doc -> Doc
csRef)) (VS (CSharpCode ValData) -> VS (CSharpCode ValData))
-> (State ValueState (CSharpCode VarData)
    -> VS (CSharpCode ValData))
-> State ValueState (CSharpCode VarData)
-> VS (CSharpCode ValData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. State ValueState (CSharpCode VarData) -> VS (CSharpCode ValData)
SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf) [State ValueState (CSharpCode VarData)]
[SVariable CSharpCode]
both [VS (CSharpCode ValData)]
-> [VS (CSharpCode ValData)] -> [VS (CSharpCode ValData)]
forall a. [a] -> [a] -> [a]
++ [VS (CSharpCode ValData)]
[SValue CSharpCode]
ins [VS (CSharpCode ValData)]
-> [VS (CSharpCode ValData)] -> [VS (CSharpCode ValData)]
forall a. [a] -> [a] -> [a]
++ (State ValueState (CSharpCode VarData) -> VS (CSharpCode ValData))
-> [State ValueState (CSharpCode VarData)]
-> [VS (CSharpCode ValData)]
forall a b. (a -> b) -> [a] -> [b]
map 
  ((CSharpCode ValData -> CSharpCode ValData)
-> VS (CSharpCode ValData) -> VS (CSharpCode ValData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue ((ValData -> ValData) -> CSharpCode ValData -> CSharpCode ValData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ((Doc -> Doc) -> ValData -> ValData
updateValDoc Doc -> Doc
csOut)) (VS (CSharpCode ValData) -> VS (CSharpCode ValData))
-> (State ValueState (CSharpCode VarData)
    -> VS (CSharpCode ValData))
-> State ValueState (CSharpCode VarData)
-> VS (CSharpCode ValData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. State ValueState (CSharpCode VarData) -> VS (CSharpCode ValData)
SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf) [State ValueState (CSharpCode VarData)]
[SVariable CSharpCode]
outs)

csVarDec :: Binding -> MSStatement CSharpCode -> MSStatement CSharpCode
csVarDec :: Binding -> MSStatement CSharpCode -> MSStatement CSharpCode
csVarDec Binding
Static MSStatement CSharpCode
_ = String
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
forall a. HasCallStack => String -> a
error String
"Static variables can't be declared locally to a function in C#. Use stateVar to make a static state variable instead."
csVarDec Binding
Dynamic MSStatement CSharpCode
d = MSStatement CSharpCode
d

csInOut :: (VSType CSharpCode -> [MSParameter CSharpCode] -> MSBody CSharpCode -> 
    SMethod CSharpCode) -> 
  [SVariable CSharpCode] -> [SVariable CSharpCode] -> [SVariable CSharpCode] -> 
  MSBody CSharpCode -> SMethod CSharpCode
csInOut :: (VSType CSharpCode
 -> [MSParameter CSharpCode]
 -> MSBody CSharpCode
 -> SMethod CSharpCode)
-> InOutFunc CSharpCode
csInOut VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
f [SVariable CSharpCode]
ins [SVariable CSharpCode
v] [] MSBody CSharpCode
b = VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
f ((CSharpCode (Variable CSharpCode) -> CSharpCode TypeData)
-> SVariable CSharpCode -> VS (CSharpCode TypeData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue CSharpCode (Variable CSharpCode) -> CSharpCode TypeData
CSharpCode (Variable CSharpCode) -> CSharpCode (Type CSharpCode)
forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable CSharpCode
v) ((SVariable CSharpCode -> State MethodState (CSharpCode ParamData))
-> [SVariable CSharpCode]
-> [State MethodState (CSharpCode ParamData)]
forall a b. (a -> b) -> [a] -> [b]
map SVariable CSharpCode -> State MethodState (CSharpCode ParamData)
SVariable CSharpCode -> MSParameter CSharpCode
forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param [SVariable CSharpCode]
ins)
  ((CSharpCode (Doc, Terminator)
 -> CSharpCode Doc
 -> CSharpCode (Doc, Terminator)
 -> CSharpCode Doc)
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
-> State MethodState (CSharpCode Doc)
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
-> State MethodState (CSharpCode Doc)
forall a b c d s.
(a -> b -> c -> d)
-> State s a -> State s b -> State s c -> State s d
on3StateValues (((Doc, Terminator) -> Doc -> (Doc, Terminator) -> Doc)
-> CSharpCode (Doc, Terminator)
-> CSharpCode Doc
-> CSharpCode (Doc, Terminator)
-> CSharpCode Doc
forall (r :: * -> *) a b c d.
Applicative r =>
(a -> b -> c -> d) -> r a -> r b -> r c -> r d
on3CodeValues (Doc, Terminator) -> Doc -> (Doc, Terminator) -> Doc
surroundBody) (SVariable CSharpCode
-> CSharpCode (Scope CSharpCode) -> MSStatement CSharpCode
forall (r :: * -> *).
DeclStatement r =>
SVariable r -> r (Scope r) -> MSStatement r
varDec SVariable CSharpCode
v CSharpCode (Scope CSharpCode)
forall (r :: * -> *). ScopeSym r => r (Scope r)
local) State MethodState (CSharpCode Doc)
MSBody CSharpCode
b (SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
ControlStatement r =>
SValue r -> MSStatement r
returnStmt (SValue CSharpCode -> MSStatement CSharpCode)
-> SValue CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ 
  SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable CSharpCode
v))
csInOut VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
f [SVariable CSharpCode]
ins [] [SVariable CSharpCode
v] MSBody CSharpCode
b = VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
f ((CSharpCode (Variable CSharpCode) -> CSharpCode TypeData)
-> SVariable CSharpCode -> VS (CSharpCode TypeData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue CSharpCode (Variable CSharpCode) -> CSharpCode TypeData
CSharpCode (Variable CSharpCode) -> CSharpCode (Type CSharpCode)
forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable CSharpCode
v) 
  ((State ValueState (CSharpCode VarData) -> MSParameter CSharpCode)
-> [State ValueState (CSharpCode VarData)]
-> [MSParameter CSharpCode]
forall a b. (a -> b) -> [a] -> [b]
map State ValueState (CSharpCode VarData) -> MSParameter CSharpCode
SVariable CSharpCode -> MSParameter CSharpCode
forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param ([State ValueState (CSharpCode VarData)]
 -> [MSParameter CSharpCode])
-> [State ValueState (CSharpCode VarData)]
-> [MSParameter CSharpCode]
forall a b. (a -> b) -> a -> b
$ State ValueState (CSharpCode VarData)
SVariable CSharpCode
v State ValueState (CSharpCode VarData)
-> [State ValueState (CSharpCode VarData)]
-> [State ValueState (CSharpCode VarData)]
forall a. a -> [a] -> [a]
: [State ValueState (CSharpCode VarData)]
[SVariable CSharpCode]
ins) ((CSharpCode Doc -> CSharpCode (Doc, Terminator) -> CSharpCode Doc)
-> State MethodState (CSharpCode Doc)
-> StateT MethodState Identity (CSharpCode (Doc, Terminator))
-> State MethodState (CSharpCode Doc)
forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues ((Doc -> (Doc, Terminator) -> Doc)
-> CSharpCode Doc -> CSharpCode (Doc, Terminator) -> CSharpCode Doc
forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues Doc -> (Doc, Terminator) -> Doc
appendToBody) State MethodState (CSharpCode Doc)
MSBody CSharpCode
b 
  (SValue CSharpCode -> MSStatement CSharpCode
forall (r :: * -> *).
ControlStatement r =>
SValue r -> MSStatement r
returnStmt (SValue CSharpCode -> MSStatement CSharpCode)
-> SValue CSharpCode -> MSStatement CSharpCode
forall a b. (a -> b) -> a -> b
$ SVariable CSharpCode -> SValue CSharpCode
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable CSharpCode
v))
csInOut VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
f [SVariable CSharpCode]
ins [SVariable CSharpCode]
outs [SVariable CSharpCode]
both MSBody CSharpCode
b = VSType CSharpCode
-> [MSParameter CSharpCode]
-> MSBody CSharpCode
-> SMethod CSharpCode
f VSType CSharpCode
forall (r :: * -> *). TypeSym r => VSType r
void ((State ValueState (CSharpCode VarData)
 -> State MethodState (CSharpCode ParamData))
-> [State ValueState (CSharpCode VarData)]
-> [State MethodState (CSharpCode ParamData)]
forall a b. (a -> b) -> [a] -> [b]
map ((CSharpCode ParamData -> CSharpCode ParamData)
-> State MethodState (CSharpCode ParamData)
-> State MethodState (CSharpCode ParamData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue ((ParamData -> ParamData)
-> CSharpCode ParamData -> CSharpCode ParamData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue 
  ((Doc -> Doc) -> ParamData -> ParamData
updateParam Doc -> Doc
csRef)) (State MethodState (CSharpCode ParamData)
 -> State MethodState (CSharpCode ParamData))
-> (State ValueState (CSharpCode VarData)
    -> State MethodState (CSharpCode ParamData))
-> State ValueState (CSharpCode VarData)
-> State MethodState (CSharpCode ParamData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. State ValueState (CSharpCode VarData)
-> State MethodState (CSharpCode ParamData)
SVariable CSharpCode -> MSParameter CSharpCode
forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param) [State ValueState (CSharpCode VarData)]
[SVariable CSharpCode]
both [State MethodState (CSharpCode ParamData)]
-> [State MethodState (CSharpCode ParamData)]
-> [State MethodState (CSharpCode ParamData)]
forall a. [a] -> [a] -> [a]
++ (State ValueState (CSharpCode VarData)
 -> State MethodState (CSharpCode ParamData))
-> [State ValueState (CSharpCode VarData)]
-> [State MethodState (CSharpCode ParamData)]
forall a b. (a -> b) -> [a] -> [b]
map State ValueState (CSharpCode VarData)
-> State MethodState (CSharpCode ParamData)
SVariable CSharpCode -> MSParameter CSharpCode
forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param [State ValueState (CSharpCode VarData)]
[SVariable CSharpCode]
ins [State MethodState (CSharpCode ParamData)]
-> [State MethodState (CSharpCode ParamData)]
-> [State MethodState (CSharpCode ParamData)]
forall a. [a] -> [a] -> [a]
++ (State ValueState (CSharpCode VarData)
 -> State MethodState (CSharpCode ParamData))
-> [State ValueState (CSharpCode VarData)]
-> [State MethodState (CSharpCode ParamData)]
forall a b. (a -> b) -> [a] -> [b]
map ((CSharpCode ParamData -> CSharpCode ParamData)
-> State MethodState (CSharpCode ParamData)
-> State MethodState (CSharpCode ParamData)
forall a b s. (a -> b) -> State s a -> State s b
onStateValue 
  ((ParamData -> ParamData)
-> CSharpCode ParamData -> CSharpCode ParamData
forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ((Doc -> Doc) -> ParamData -> ParamData
updateParam Doc -> Doc
csOut)) (State MethodState (CSharpCode ParamData)
 -> State MethodState (CSharpCode ParamData))
-> (State ValueState (CSharpCode VarData)
    -> State MethodState (CSharpCode ParamData))
-> State ValueState (CSharpCode VarData)
-> State MethodState (CSharpCode ParamData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. State ValueState (CSharpCode VarData)
-> State MethodState (CSharpCode ParamData)
SVariable CSharpCode -> MSParameter CSharpCode
forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param) [State ValueState (CSharpCode VarData)]
[SVariable CSharpCode]
outs) MSBody CSharpCode
b