{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}
{-# OPTIONS_GHC -Wno-dodgy-exports #-}
{-# OPTIONS_GHC -Wno-unused-matches #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Capnp.Gen.Calculator.Pure(Capnp.Gen.ById.X85150b117366d14b.Operator(..)
                                ,Calculator(..)
                                ,Calculator'server_(..)
                                ,export_Calculator
                                ,Calculator'evaluate'params(..)
                                ,Calculator'evaluate'results(..)
                                ,Calculator'defFunction'params(..)
                                ,Calculator'defFunction'results(..)
                                ,Calculator'getOperator'params(..)
                                ,Calculator'getOperator'results(..)
                                ,Expression(..)
                                ,Expression'call(..)
                                ,Value(..)
                                ,Value'server_(..)
                                ,export_Value
                                ,Value'read'params(..)
                                ,Value'read'results(..)
                                ,Function(..)
                                ,Function'server_(..)
                                ,export_Function
                                ,Function'call'params(..)
                                ,Function'call'results(..)) where
import qualified Capnp.GenHelpers.ReExports.Data.Vector as V
import qualified Capnp.GenHelpers.ReExports.Data.Text as T
import qualified Capnp.GenHelpers.ReExports.Data.ByteString as BS
import qualified Capnp.GenHelpers.ReExports.Data.Default as Default
import qualified GHC.Generics as Generics
import qualified Control.Monad.IO.Class as MonadIO
import qualified Capnp.Untyped.Pure as UntypedPure
import qualified Capnp.Untyped as Untyped
import qualified Capnp.Message as Message
import qualified Capnp.Classes as Classes
import qualified Capnp.Basics.Pure as BasicsPure
import qualified Capnp.GenHelpers.Pure as GenHelpersPure
import qualified Capnp.Rpc.Untyped as Rpc
import qualified Capnp.Rpc.Server as Server
import qualified Capnp.GenHelpers.Rpc as RpcHelpers
import qualified Capnp.GenHelpers.ReExports.Control.Concurrent.STM as STM
import qualified Capnp.GenHelpers.ReExports.Control.Monad.STM.Class as STM
import qualified Capnp.GenHelpers.ReExports.Supervisors as Supervisors
import qualified Capnp.Gen.ById.X85150b117366d14b
import qualified Prelude as Std_
import qualified Data.Word as Std_
import qualified Data.Int as Std_
import Prelude ((<$>), (<*>), (>>=))
newtype Calculator 
    = Calculator Message.Client
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
class ((MonadIO.MonadIO m)) => (Calculator'server_ m cap) where
    {-# MINIMAL calculator'evaluate,calculator'defFunction,calculator'getOperator #-}
    calculator'evaluate :: cap -> (Server.MethodHandler m Calculator'evaluate'params Calculator'evaluate'results)
    calculator'evaluate _ = Server.methodUnimplemented
    calculator'defFunction :: cap -> (Server.MethodHandler m Calculator'defFunction'params Calculator'defFunction'results)
    calculator'defFunction _ = Server.methodUnimplemented
    calculator'getOperator :: cap -> (Server.MethodHandler m Calculator'getOperator'params Calculator'getOperator'results)
    calculator'getOperator _ = Server.methodUnimplemented
export_Calculator :: ((Calculator'server_ Std_.IO a)
                     ,(STM.MonadSTM m)) => Supervisors.Supervisor -> a -> (m Calculator)
export_Calculator sup_ server_ = (STM.liftSTM (Calculator <$> (Rpc.export sup_ Server.ServerOps{handleStop = (Std_.pure ())
                                                                                               ,handleCall = (\interfaceId_ methodId_ -> case interfaceId_ of
                                                                                                   10923537602090224694 ->
                                                                                                       case methodId_ of
                                                                                                           0 ->
                                                                                                               (Server.toUntypedHandler (calculator'evaluate server_))
                                                                                                           1 ->
                                                                                                               (Server.toUntypedHandler (calculator'defFunction server_))
                                                                                                           2 ->
                                                                                                               (Server.toUntypedHandler (calculator'getOperator server_))
                                                                                                           _ ->
                                                                                                               Server.methodUnimplemented
                                                                                                   _ ->
                                                                                                       Server.methodUnimplemented)})))
instance (Rpc.IsClient Calculator) where
    fromClient  = Calculator
    toClient (Calculator client) = client
instance (Classes.FromPtr msg Calculator) where
    fromPtr  = RpcHelpers.isClientFromPtr
instance (Classes.ToPtr s Calculator) where
    toPtr  = RpcHelpers.isClientToPtr
instance (Classes.Decerialize Calculator) where
    type Cerial msg Calculator = (Capnp.Gen.ById.X85150b117366d14b.Calculator msg)
    decerialize (Capnp.Gen.ById.X85150b117366d14b.Calculator'newtype_ maybeCap) = case maybeCap of
        (Std_.Nothing) ->
            (Std_.pure (Calculator Message.nullClient))
        (Std_.Just cap) ->
            (Calculator <$> (Untyped.getClient cap))
instance (Classes.Cerialize Calculator) where
    cerialize msg (Calculator client) = (Capnp.Gen.ById.X85150b117366d14b.Calculator'newtype_ <$> (Std_.Just <$> (Untyped.appendCap msg client)))
instance (Calculator'server_ Std_.IO Calculator) where
    calculator'evaluate (Calculator client) = (Rpc.clientMethodHandler 10923537602090224694 0 client)
    calculator'defFunction (Calculator client) = (Rpc.clientMethodHandler 10923537602090224694 1 client)
    calculator'getOperator (Calculator client) = (Rpc.clientMethodHandler 10923537602090224694 2 client)
data Calculator'evaluate'params 
    = Calculator'evaluate'params 
        {expression :: Expression}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Calculator'evaluate'params) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Calculator'evaluate'params) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Calculator'evaluate'params) where
    type Cerial msg Calculator'evaluate'params = (Capnp.Gen.ById.X85150b117366d14b.Calculator'evaluate'params msg)
    decerialize raw = (Calculator'evaluate'params <$> ((Capnp.Gen.ById.X85150b117366d14b.get_Calculator'evaluate'params'expression raw) >>= Classes.decerialize))
instance (Classes.Marshal Calculator'evaluate'params) where
    marshalInto raw_ value_ = case value_ of
        Calculator'evaluate'params{..} ->
            (do
                ((Classes.cerialize (Untyped.message raw_) expression) >>= (Capnp.Gen.ById.X85150b117366d14b.set_Calculator'evaluate'params'expression raw_))
                (Std_.pure ())
                )
instance (Classes.Cerialize Calculator'evaluate'params)
instance (Classes.Cerialize (V.Vector Calculator'evaluate'params)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Calculator'evaluate'params))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Calculator'evaluate'params)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Calculator'evaluate'params))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'evaluate'params)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'evaluate'params))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'evaluate'params)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
data Calculator'evaluate'results 
    = Calculator'evaluate'results 
        {value :: Value}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Calculator'evaluate'results) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Calculator'evaluate'results) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Calculator'evaluate'results) where
    type Cerial msg Calculator'evaluate'results = (Capnp.Gen.ById.X85150b117366d14b.Calculator'evaluate'results msg)
    decerialize raw = (Calculator'evaluate'results <$> ((Capnp.Gen.ById.X85150b117366d14b.get_Calculator'evaluate'results'value raw) >>= Classes.decerialize))
instance (Classes.Marshal Calculator'evaluate'results) where
    marshalInto raw_ value_ = case value_ of
        Calculator'evaluate'results{..} ->
            (do
                ((Classes.cerialize (Untyped.message raw_) value) >>= (Capnp.Gen.ById.X85150b117366d14b.set_Calculator'evaluate'results'value raw_))
                (Std_.pure ())
                )
instance (Classes.Cerialize Calculator'evaluate'results)
instance (Classes.Cerialize (V.Vector Calculator'evaluate'results)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Calculator'evaluate'results))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Calculator'evaluate'results)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Calculator'evaluate'results))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'evaluate'results)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'evaluate'results))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'evaluate'results)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
data Calculator'defFunction'params 
    = Calculator'defFunction'params 
        {paramCount :: Std_.Int32
        ,body :: Expression}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Calculator'defFunction'params) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Calculator'defFunction'params) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Calculator'defFunction'params) where
    type Cerial msg Calculator'defFunction'params = (Capnp.Gen.ById.X85150b117366d14b.Calculator'defFunction'params msg)
    decerialize raw = (Calculator'defFunction'params <$> (Capnp.Gen.ById.X85150b117366d14b.get_Calculator'defFunction'params'paramCount raw)
                                                     <*> ((Capnp.Gen.ById.X85150b117366d14b.get_Calculator'defFunction'params'body raw) >>= Classes.decerialize))
instance (Classes.Marshal Calculator'defFunction'params) where
    marshalInto raw_ value_ = case value_ of
        Calculator'defFunction'params{..} ->
            (do
                (Capnp.Gen.ById.X85150b117366d14b.set_Calculator'defFunction'params'paramCount raw_ paramCount)
                ((Classes.cerialize (Untyped.message raw_) body) >>= (Capnp.Gen.ById.X85150b117366d14b.set_Calculator'defFunction'params'body raw_))
                (Std_.pure ())
                )
instance (Classes.Cerialize Calculator'defFunction'params)
instance (Classes.Cerialize (V.Vector Calculator'defFunction'params)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Calculator'defFunction'params))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Calculator'defFunction'params)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Calculator'defFunction'params))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'defFunction'params)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'defFunction'params))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'defFunction'params)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
data Calculator'defFunction'results 
    = Calculator'defFunction'results 
        {func :: Function}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Calculator'defFunction'results) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Calculator'defFunction'results) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Calculator'defFunction'results) where
    type Cerial msg Calculator'defFunction'results = (Capnp.Gen.ById.X85150b117366d14b.Calculator'defFunction'results msg)
    decerialize raw = (Calculator'defFunction'results <$> ((Capnp.Gen.ById.X85150b117366d14b.get_Calculator'defFunction'results'func raw) >>= Classes.decerialize))
instance (Classes.Marshal Calculator'defFunction'results) where
    marshalInto raw_ value_ = case value_ of
        Calculator'defFunction'results{..} ->
            (do
                ((Classes.cerialize (Untyped.message raw_) func) >>= (Capnp.Gen.ById.X85150b117366d14b.set_Calculator'defFunction'results'func raw_))
                (Std_.pure ())
                )
instance (Classes.Cerialize Calculator'defFunction'results)
instance (Classes.Cerialize (V.Vector Calculator'defFunction'results)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Calculator'defFunction'results))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Calculator'defFunction'results)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Calculator'defFunction'results))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'defFunction'results)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'defFunction'results))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'defFunction'results)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
data Calculator'getOperator'params 
    = Calculator'getOperator'params 
        {op :: Capnp.Gen.ById.X85150b117366d14b.Operator}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Calculator'getOperator'params) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Calculator'getOperator'params) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Calculator'getOperator'params) where
    type Cerial msg Calculator'getOperator'params = (Capnp.Gen.ById.X85150b117366d14b.Calculator'getOperator'params msg)
    decerialize raw = (Calculator'getOperator'params <$> (Capnp.Gen.ById.X85150b117366d14b.get_Calculator'getOperator'params'op raw))
instance (Classes.Marshal Calculator'getOperator'params) where
    marshalInto raw_ value_ = case value_ of
        Calculator'getOperator'params{..} ->
            (do
                (Capnp.Gen.ById.X85150b117366d14b.set_Calculator'getOperator'params'op raw_ op)
                (Std_.pure ())
                )
instance (Classes.Cerialize Calculator'getOperator'params)
instance (Classes.Cerialize (V.Vector Calculator'getOperator'params)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Calculator'getOperator'params))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Calculator'getOperator'params)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Calculator'getOperator'params))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'getOperator'params)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'getOperator'params))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'getOperator'params)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
data Calculator'getOperator'results 
    = Calculator'getOperator'results 
        {func :: Function}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Calculator'getOperator'results) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Calculator'getOperator'results) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Calculator'getOperator'results) where
    type Cerial msg Calculator'getOperator'results = (Capnp.Gen.ById.X85150b117366d14b.Calculator'getOperator'results msg)
    decerialize raw = (Calculator'getOperator'results <$> ((Capnp.Gen.ById.X85150b117366d14b.get_Calculator'getOperator'results'func raw) >>= Classes.decerialize))
instance (Classes.Marshal Calculator'getOperator'results) where
    marshalInto raw_ value_ = case value_ of
        Calculator'getOperator'results{..} ->
            (do
                ((Classes.cerialize (Untyped.message raw_) func) >>= (Capnp.Gen.ById.X85150b117366d14b.set_Calculator'getOperator'results'func raw_))
                (Std_.pure ())
                )
instance (Classes.Cerialize Calculator'getOperator'results)
instance (Classes.Cerialize (V.Vector Calculator'getOperator'results)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Calculator'getOperator'results))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Calculator'getOperator'results)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Calculator'getOperator'results))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'getOperator'results)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'getOperator'results))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Calculator'getOperator'results)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
data Expression 
    = Expression'literal Std_.Double
    | Expression'previousResult Value
    | Expression'parameter Std_.Word32
    | Expression'call Expression'call
    | Expression'unknown' Std_.Word16
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Expression) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Expression) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Expression) where
    type Cerial msg Expression = (Capnp.Gen.ById.X85150b117366d14b.Expression msg)
    decerialize raw = (do
        raw <- (Capnp.Gen.ById.X85150b117366d14b.get_Expression' raw)
        case raw of
            (Capnp.Gen.ById.X85150b117366d14b.Expression'literal raw) ->
                (Std_.pure (Expression'literal raw))
            (Capnp.Gen.ById.X85150b117366d14b.Expression'previousResult raw) ->
                (Expression'previousResult <$> (Classes.decerialize raw))
            (Capnp.Gen.ById.X85150b117366d14b.Expression'parameter raw) ->
                (Std_.pure (Expression'parameter raw))
            (Capnp.Gen.ById.X85150b117366d14b.Expression'call raw) ->
                (Expression'call <$> (Classes.decerialize raw))
            (Capnp.Gen.ById.X85150b117366d14b.Expression'unknown' tag) ->
                (Std_.pure (Expression'unknown' tag))
        )
instance (Classes.Marshal Expression) where
    marshalInto raw_ value_ = case value_ of
        (Expression'literal arg_) ->
            (Capnp.Gen.ById.X85150b117366d14b.set_Expression'literal raw_ arg_)
        (Expression'previousResult arg_) ->
            ((Classes.cerialize (Untyped.message raw_) arg_) >>= (Capnp.Gen.ById.X85150b117366d14b.set_Expression'previousResult raw_))
        (Expression'parameter arg_) ->
            (Capnp.Gen.ById.X85150b117366d14b.set_Expression'parameter raw_ arg_)
        (Expression'call arg_) ->
            (do
                raw_ <- (Capnp.Gen.ById.X85150b117366d14b.set_Expression'call raw_)
                (Classes.marshalInto raw_ arg_)
                )
        (Expression'unknown' tag) ->
            (Capnp.Gen.ById.X85150b117366d14b.set_Expression'unknown' raw_ tag)
instance (Classes.Cerialize Expression)
instance (Classes.Cerialize (V.Vector Expression)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Expression))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Expression)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Expression))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Expression)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Expression))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Expression)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
data Expression'call 
    = Expression'call' 
        {function :: Function
        ,params :: (V.Vector Expression)}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Expression'call) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Expression'call) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Expression'call) where
    type Cerial msg Expression'call = (Capnp.Gen.ById.X85150b117366d14b.Expression'call msg)
    decerialize raw = (Expression'call' <$> ((Capnp.Gen.ById.X85150b117366d14b.get_Expression'call'function raw) >>= Classes.decerialize)
                                        <*> ((Capnp.Gen.ById.X85150b117366d14b.get_Expression'call'params raw) >>= Classes.decerialize))
instance (Classes.Marshal Expression'call) where
    marshalInto raw_ value_ = case value_ of
        Expression'call'{..} ->
            (do
                ((Classes.cerialize (Untyped.message raw_) function) >>= (Capnp.Gen.ById.X85150b117366d14b.set_Expression'call'function raw_))
                ((Classes.cerialize (Untyped.message raw_) params) >>= (Capnp.Gen.ById.X85150b117366d14b.set_Expression'call'params raw_))
                (Std_.pure ())
                )
newtype Value 
    = Value Message.Client
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
class ((MonadIO.MonadIO m)) => (Value'server_ m cap) where
    {-# MINIMAL value'read #-}
    value'read :: cap -> (Server.MethodHandler m Value'read'params Value'read'results)
    value'read _ = Server.methodUnimplemented
export_Value :: ((Value'server_ Std_.IO a)
                ,(STM.MonadSTM m)) => Supervisors.Supervisor -> a -> (m Value)
export_Value sup_ server_ = (STM.liftSTM (Value <$> (Rpc.export sup_ Server.ServerOps{handleStop = (Std_.pure ())
                                                                                     ,handleCall = (\interfaceId_ methodId_ -> case interfaceId_ of
                                                                                         14116142932258867410 ->
                                                                                             case methodId_ of
                                                                                                 0 ->
                                                                                                     (Server.toUntypedHandler (value'read server_))
                                                                                                 _ ->
                                                                                                     Server.methodUnimplemented
                                                                                         _ ->
                                                                                             Server.methodUnimplemented)})))
instance (Rpc.IsClient Value) where
    fromClient  = Value
    toClient (Value client) = client
instance (Classes.FromPtr msg Value) where
    fromPtr  = RpcHelpers.isClientFromPtr
instance (Classes.ToPtr s Value) where
    toPtr  = RpcHelpers.isClientToPtr
instance (Classes.Decerialize Value) where
    type Cerial msg Value = (Capnp.Gen.ById.X85150b117366d14b.Value msg)
    decerialize (Capnp.Gen.ById.X85150b117366d14b.Value'newtype_ maybeCap) = case maybeCap of
        (Std_.Nothing) ->
            (Std_.pure (Value Message.nullClient))
        (Std_.Just cap) ->
            (Value <$> (Untyped.getClient cap))
instance (Classes.Cerialize Value) where
    cerialize msg (Value client) = (Capnp.Gen.ById.X85150b117366d14b.Value'newtype_ <$> (Std_.Just <$> (Untyped.appendCap msg client)))
instance (Value'server_ Std_.IO Value) where
    value'read (Value client) = (Rpc.clientMethodHandler 14116142932258867410 0 client)
data Value'read'params 
    = Value'read'params 
        {}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Value'read'params) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Value'read'params) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Value'read'params) where
    type Cerial msg Value'read'params = (Capnp.Gen.ById.X85150b117366d14b.Value'read'params msg)
    decerialize raw = (Std_.pure Value'read'params)
instance (Classes.Marshal Value'read'params) where
    marshalInto raw_ value_ = case value_ of
        (Value'read'params) ->
            (do
                (Std_.pure ())
                )
instance (Classes.Cerialize Value'read'params)
instance (Classes.Cerialize (V.Vector Value'read'params)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Value'read'params))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Value'read'params)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Value'read'params))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Value'read'params)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Value'read'params))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Value'read'params)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
data Value'read'results 
    = Value'read'results 
        {value :: Std_.Double}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Value'read'results) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Value'read'results) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Value'read'results) where
    type Cerial msg Value'read'results = (Capnp.Gen.ById.X85150b117366d14b.Value'read'results msg)
    decerialize raw = (Value'read'results <$> (Capnp.Gen.ById.X85150b117366d14b.get_Value'read'results'value raw))
instance (Classes.Marshal Value'read'results) where
    marshalInto raw_ value_ = case value_ of
        Value'read'results{..} ->
            (do
                (Capnp.Gen.ById.X85150b117366d14b.set_Value'read'results'value raw_ value)
                (Std_.pure ())
                )
instance (Classes.Cerialize Value'read'results)
instance (Classes.Cerialize (V.Vector Value'read'results)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Value'read'results))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Value'read'results)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Value'read'results))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Value'read'results)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Value'read'results))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Value'read'results)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
newtype Function 
    = Function Message.Client
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
class ((MonadIO.MonadIO m)) => (Function'server_ m cap) where
    {-# MINIMAL function'call #-}
    function'call :: cap -> (Server.MethodHandler m Function'call'params Function'call'results)
    function'call _ = Server.methodUnimplemented
export_Function :: ((Function'server_ Std_.IO a)
                   ,(STM.MonadSTM m)) => Supervisors.Supervisor -> a -> (m Function)
export_Function sup_ server_ = (STM.liftSTM (Function <$> (Rpc.export sup_ Server.ServerOps{handleStop = (Std_.pure ())
                                                                                           ,handleCall = (\interfaceId_ methodId_ -> case interfaceId_ of
                                                                                               17143016017778443156 ->
                                                                                                   case methodId_ of
                                                                                                       0 ->
                                                                                                           (Server.toUntypedHandler (function'call server_))
                                                                                                       _ ->
                                                                                                           Server.methodUnimplemented
                                                                                               _ ->
                                                                                                   Server.methodUnimplemented)})))
instance (Rpc.IsClient Function) where
    fromClient  = Function
    toClient (Function client) = client
instance (Classes.FromPtr msg Function) where
    fromPtr  = RpcHelpers.isClientFromPtr
instance (Classes.ToPtr s Function) where
    toPtr  = RpcHelpers.isClientToPtr
instance (Classes.Decerialize Function) where
    type Cerial msg Function = (Capnp.Gen.ById.X85150b117366d14b.Function msg)
    decerialize (Capnp.Gen.ById.X85150b117366d14b.Function'newtype_ maybeCap) = case maybeCap of
        (Std_.Nothing) ->
            (Std_.pure (Function Message.nullClient))
        (Std_.Just cap) ->
            (Function <$> (Untyped.getClient cap))
instance (Classes.Cerialize Function) where
    cerialize msg (Function client) = (Capnp.Gen.ById.X85150b117366d14b.Function'newtype_ <$> (Std_.Just <$> (Untyped.appendCap msg client)))
instance (Function'server_ Std_.IO Function) where
    function'call (Function client) = (Rpc.clientMethodHandler 17143016017778443156 0 client)
data Function'call'params 
    = Function'call'params 
        {params :: (V.Vector Std_.Double)}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Function'call'params) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Function'call'params) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Function'call'params) where
    type Cerial msg Function'call'params = (Capnp.Gen.ById.X85150b117366d14b.Function'call'params msg)
    decerialize raw = (Function'call'params <$> ((Capnp.Gen.ById.X85150b117366d14b.get_Function'call'params'params raw) >>= Classes.decerialize))
instance (Classes.Marshal Function'call'params) where
    marshalInto raw_ value_ = case value_ of
        Function'call'params{..} ->
            (do
                ((Classes.cerialize (Untyped.message raw_) params) >>= (Capnp.Gen.ById.X85150b117366d14b.set_Function'call'params'params raw_))
                (Std_.pure ())
                )
instance (Classes.Cerialize Function'call'params)
instance (Classes.Cerialize (V.Vector Function'call'params)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Function'call'params))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Function'call'params)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Function'call'params))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Function'call'params)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Function'call'params))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Function'call'params)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
data Function'call'results 
    = Function'call'results 
        {value :: Std_.Double}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Function'call'results) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Function'call'results) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Function'call'results) where
    type Cerial msg Function'call'results = (Capnp.Gen.ById.X85150b117366d14b.Function'call'results msg)
    decerialize raw = (Function'call'results <$> (Capnp.Gen.ById.X85150b117366d14b.get_Function'call'results'value raw))
instance (Classes.Marshal Function'call'results) where
    marshalInto raw_ value_ = case value_ of
        Function'call'results{..} ->
            (do
                (Capnp.Gen.ById.X85150b117366d14b.set_Function'call'results'value raw_ value)
                (Std_.pure ())
                )
instance (Classes.Cerialize Function'call'results)
instance (Classes.Cerialize (V.Vector Function'call'results)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Function'call'results))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Function'call'results)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Function'call'results))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Function'call'results)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Function'call'results))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Function'call'results)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Decerialize Capnp.Gen.ById.X85150b117366d14b.Operator) where
    type Cerial msg Capnp.Gen.ById.X85150b117366d14b.Operator = Capnp.Gen.ById.X85150b117366d14b.Operator
    decerialize  = Std_.pure
instance (Classes.Cerialize Capnp.Gen.ById.X85150b117366d14b.Operator) where
    cerialize _ = Std_.pure
instance (Classes.Cerialize (V.Vector Capnp.Gen.ById.X85150b117366d14b.Operator)) where
    cerialize  = Classes.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector Capnp.Gen.ById.X85150b117366d14b.Operator))) where
    cerialize  = Classes.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Capnp.Gen.ById.X85150b117366d14b.Operator)))) where
    cerialize  = Classes.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Capnp.Gen.ById.X85150b117366d14b.Operator))))) where
    cerialize  = Classes.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Capnp.Gen.ById.X85150b117366d14b.Operator)))))) where
    cerialize  = Classes.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Capnp.Gen.ById.X85150b117366d14b.Operator))))))) where
    cerialize  = Classes.cerializeBasicVec