{-# 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.Echo.Pure(Echo(..)
                          ,Echo'server_(..)
                          ,export_Echo
                          ,Echo'echo'params(..)
                          ,Echo'echo'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.Xd0a87f36fa0182f5
import qualified Prelude as Std_
import qualified Data.Word as Std_
import qualified Data.Int as Std_
import Prelude ((<$>), (<*>), (>>=))
newtype Echo 
    = Echo Message.Client
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
class ((MonadIO.MonadIO m)) => (Echo'server_ m cap) where
    {-# MINIMAL echo'echo #-}
    echo'echo :: cap -> (Server.MethodHandler m Echo'echo'params Echo'echo'results)
    echo'echo _ = Server.methodUnimplemented
export_Echo :: ((Echo'server_ Std_.IO a)
               ,(STM.MonadSTM m)) => Supervisors.Supervisor -> a -> (m Echo)
export_Echo sup_ server_ = (STM.liftSTM (Echo <$> (Rpc.export sup_ Server.ServerOps{handleStop = (Std_.pure ())
                                                                                   ,handleCall = (\interfaceId_ methodId_ -> case interfaceId_ of
                                                                                       16940812395455687611 ->
                                                                                           case methodId_ of
                                                                                               0 ->
                                                                                                   (Server.toUntypedHandler (echo'echo server_))
                                                                                               _ ->
                                                                                                   Server.methodUnimplemented
                                                                                       _ ->
                                                                                           Server.methodUnimplemented)})))
instance (Rpc.IsClient Echo) where
    fromClient  = Echo
    toClient (Echo client) = client
instance (Classes.FromPtr msg Echo) where
    fromPtr  = RpcHelpers.isClientFromPtr
instance (Classes.ToPtr s Echo) where
    toPtr  = RpcHelpers.isClientToPtr
instance (Classes.Decerialize Echo) where
    type Cerial msg Echo = (Capnp.Gen.ById.Xd0a87f36fa0182f5.Echo msg)
    decerialize (Capnp.Gen.ById.Xd0a87f36fa0182f5.Echo'newtype_ maybeCap) = case maybeCap of
        (Std_.Nothing) ->
            (Std_.pure (Echo Message.nullClient))
        (Std_.Just cap) ->
            (Echo <$> (Untyped.getClient cap))
instance (Classes.Cerialize Echo) where
    cerialize msg (Echo client) = (Capnp.Gen.ById.Xd0a87f36fa0182f5.Echo'newtype_ <$> (Std_.Just <$> (Untyped.appendCap msg client)))
instance (Echo'server_ Std_.IO Echo) where
    echo'echo (Echo client) = (Rpc.clientMethodHandler 16940812395455687611 0 client)
data Echo'echo'params 
    = Echo'echo'params 
        {query :: T.Text}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Echo'echo'params) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Echo'echo'params) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Echo'echo'params) where
    type Cerial msg Echo'echo'params = (Capnp.Gen.ById.Xd0a87f36fa0182f5.Echo'echo'params msg)
    decerialize raw = (Echo'echo'params <$> ((Capnp.Gen.ById.Xd0a87f36fa0182f5.get_Echo'echo'params'query raw) >>= Classes.decerialize))
instance (Classes.Marshal Echo'echo'params) where
    marshalInto raw_ value_ = case value_ of
        Echo'echo'params{..} ->
            (do
                ((Classes.cerialize (Untyped.message raw_) query) >>= (Capnp.Gen.ById.Xd0a87f36fa0182f5.set_Echo'echo'params'query raw_))
                (Std_.pure ())
                )
instance (Classes.Cerialize Echo'echo'params)
instance (Classes.Cerialize (V.Vector Echo'echo'params)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Echo'echo'params))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Echo'echo'params)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Echo'echo'params))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Echo'echo'params)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Echo'echo'params))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Echo'echo'params)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
data Echo'echo'results 
    = Echo'echo'results 
        {reply :: T.Text}
    deriving(Std_.Show
            ,Std_.Eq
            ,Generics.Generic)
instance (Default.Default Echo'echo'results) where
    def  = GenHelpersPure.defaultStruct
instance (Classes.FromStruct Message.ConstMsg Echo'echo'results) where
    fromStruct struct = ((Classes.fromStruct struct) >>= Classes.decerialize)
instance (Classes.Decerialize Echo'echo'results) where
    type Cerial msg Echo'echo'results = (Capnp.Gen.ById.Xd0a87f36fa0182f5.Echo'echo'results msg)
    decerialize raw = (Echo'echo'results <$> ((Capnp.Gen.ById.Xd0a87f36fa0182f5.get_Echo'echo'results'reply raw) >>= Classes.decerialize))
instance (Classes.Marshal Echo'echo'results) where
    marshalInto raw_ value_ = case value_ of
        Echo'echo'results{..} ->
            (do
                ((Classes.cerialize (Untyped.message raw_) reply) >>= (Capnp.Gen.ById.Xd0a87f36fa0182f5.set_Echo'echo'results'reply raw_))
                (Std_.pure ())
                )
instance (Classes.Cerialize Echo'echo'results)
instance (Classes.Cerialize (V.Vector Echo'echo'results)) where
    cerialize  = GenHelpersPure.cerializeCompositeVec
instance (Classes.Cerialize (V.Vector (V.Vector Echo'echo'results))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector Echo'echo'results)))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector Echo'echo'results))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Echo'echo'results)))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Echo'echo'results))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec
instance (Classes.Cerialize (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector (V.Vector Echo'echo'results)))))))) where
    cerialize  = GenHelpersPure.cerializeBasicVec