packages feed

capnp-0.10.0.0: examples/gen/lib/Capnp/Gen/Echo.hs

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}
{-# OPTIONS_GHC -Wno-dodgy-exports #-}
{-# OPTIONS_GHC -Wno-unused-matches #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
module Capnp.Gen.Echo where
import qualified Capnp.Message as Message
import qualified Capnp.Untyped as Untyped
import qualified Capnp.Basics as Basics
import qualified Capnp.GenHelpers as GenHelpers
import qualified Capnp.Classes as Classes
import qualified GHC.Generics as Generics
import qualified Capnp.Bits as Std_
import qualified Data.Maybe as Std_
import qualified Capnp.GenHelpers.ReExports.Data.ByteString as BS
import qualified Prelude as Std_
import qualified Data.Word as Std_
import qualified Data.Int as Std_
import Prelude ((<$>), (<*>), (>>=))
newtype Echo msg
    = Echo'newtype_ (Std_.Maybe (Untyped.Cap msg))
instance (Classes.FromPtr msg (Echo msg)) where
    fromPtr msg ptr = (Echo'newtype_ <$> (Classes.fromPtr msg ptr))
instance (Classes.ToPtr s (Echo (Message.Mut s))) where
    toPtr msg (Echo'newtype_ (Std_.Nothing)) = (Std_.pure Std_.Nothing)
    toPtr msg (Echo'newtype_ (Std_.Just cap)) = (Std_.pure (Std_.Just (Untyped.PtrCap cap)))
newtype Echo'echo'params msg
    = Echo'echo'params'newtype_ (Untyped.Struct msg)
instance (Classes.FromStruct msg (Echo'echo'params msg)) where
    fromStruct struct = (Std_.pure (Echo'echo'params'newtype_ struct))
instance (Classes.ToStruct msg (Echo'echo'params msg)) where
    toStruct (Echo'echo'params'newtype_ struct) = struct
instance (Untyped.HasMessage (Echo'echo'params mut) mut) where
    message (Echo'echo'params'newtype_ struct) = (Untyped.message struct)
instance (Untyped.MessageDefault (Echo'echo'params mut) mut) where
    messageDefault msg = (Echo'echo'params'newtype_ <$> (Untyped.messageDefault msg))
instance (Classes.FromPtr msg (Echo'echo'params msg)) where
    fromPtr msg ptr = (Echo'echo'params'newtype_ <$> (Classes.fromPtr msg ptr))
instance (Classes.ToPtr s (Echo'echo'params (Message.Mut s))) where
    toPtr msg (Echo'echo'params'newtype_ struct) = (Classes.toPtr msg struct)
instance (Classes.Allocate s (Echo'echo'params (Message.Mut s))) where
    new msg = (Echo'echo'params'newtype_ <$> (Untyped.allocStruct msg 0 1))
instance (Basics.ListElem mut (Echo'echo'params mut)) where
    newtype List mut (Echo'echo'params mut)
        = Echo'echo'params'List_ (Untyped.ListOf mut (Untyped.Struct mut))
    listFromPtr msg ptr = (Echo'echo'params'List_ <$> (Classes.fromPtr msg ptr))
    toUntypedList (Echo'echo'params'List_ l) = (Untyped.ListStruct l)
    length (Echo'echo'params'List_ l) = (Untyped.length l)
    index i (Echo'echo'params'List_ l) = (do
        elt <- (Untyped.index i l)
        (Classes.fromStruct elt)
        )
instance (Basics.MutListElem s (Echo'echo'params (Message.Mut s))) where
    setIndex (Echo'echo'params'newtype_ elt) i (Echo'echo'params'List_ l) = (Untyped.setIndex elt i l)
    newList msg len = (Echo'echo'params'List_ <$> (Untyped.allocCompositeList msg 0 1 len))
get_Echo'echo'params'query :: ((Untyped.ReadCtx m msg)
                              ,(Classes.FromPtr msg (Basics.Text msg))) => (Echo'echo'params msg) -> (m (Basics.Text msg))
get_Echo'echo'params'query (Echo'echo'params'newtype_ struct) = (do
    ptr <- (Untyped.getPtr 0 struct)
    (Classes.fromPtr (Untyped.message struct) ptr)
    )
set_Echo'echo'params'query :: ((Untyped.RWCtx m s)
                              ,(Classes.ToPtr s (Basics.Text (Message.Mut s)))) => (Echo'echo'params (Message.Mut s)) -> (Basics.Text (Message.Mut s)) -> (m ())
set_Echo'echo'params'query (Echo'echo'params'newtype_ struct) value = (do
    ptr <- (Classes.toPtr (Untyped.message struct) value)
    (Untyped.setPtr ptr 0 struct)
    )
has_Echo'echo'params'query :: ((Untyped.ReadCtx m msg)) => (Echo'echo'params msg) -> (m Std_.Bool)
has_Echo'echo'params'query (Echo'echo'params'newtype_ struct) = (Std_.isJust <$> (Untyped.getPtr 0 struct))
new_Echo'echo'params'query :: ((Untyped.RWCtx m s)) => Std_.Int -> (Echo'echo'params (Message.Mut s)) -> (m (Basics.Text (Message.Mut s)))
new_Echo'echo'params'query len struct = (do
    result <- (Basics.newText (Untyped.message struct) len)
    (set_Echo'echo'params'query struct result)
    (Std_.pure result)
    )
newtype Echo'echo'results msg
    = Echo'echo'results'newtype_ (Untyped.Struct msg)
instance (Classes.FromStruct msg (Echo'echo'results msg)) where
    fromStruct struct = (Std_.pure (Echo'echo'results'newtype_ struct))
instance (Classes.ToStruct msg (Echo'echo'results msg)) where
    toStruct (Echo'echo'results'newtype_ struct) = struct
instance (Untyped.HasMessage (Echo'echo'results mut) mut) where
    message (Echo'echo'results'newtype_ struct) = (Untyped.message struct)
instance (Untyped.MessageDefault (Echo'echo'results mut) mut) where
    messageDefault msg = (Echo'echo'results'newtype_ <$> (Untyped.messageDefault msg))
instance (Classes.FromPtr msg (Echo'echo'results msg)) where
    fromPtr msg ptr = (Echo'echo'results'newtype_ <$> (Classes.fromPtr msg ptr))
instance (Classes.ToPtr s (Echo'echo'results (Message.Mut s))) where
    toPtr msg (Echo'echo'results'newtype_ struct) = (Classes.toPtr msg struct)
instance (Classes.Allocate s (Echo'echo'results (Message.Mut s))) where
    new msg = (Echo'echo'results'newtype_ <$> (Untyped.allocStruct msg 0 1))
instance (Basics.ListElem mut (Echo'echo'results mut)) where
    newtype List mut (Echo'echo'results mut)
        = Echo'echo'results'List_ (Untyped.ListOf mut (Untyped.Struct mut))
    listFromPtr msg ptr = (Echo'echo'results'List_ <$> (Classes.fromPtr msg ptr))
    toUntypedList (Echo'echo'results'List_ l) = (Untyped.ListStruct l)
    length (Echo'echo'results'List_ l) = (Untyped.length l)
    index i (Echo'echo'results'List_ l) = (do
        elt <- (Untyped.index i l)
        (Classes.fromStruct elt)
        )
instance (Basics.MutListElem s (Echo'echo'results (Message.Mut s))) where
    setIndex (Echo'echo'results'newtype_ elt) i (Echo'echo'results'List_ l) = (Untyped.setIndex elt i l)
    newList msg len = (Echo'echo'results'List_ <$> (Untyped.allocCompositeList msg 0 1 len))
get_Echo'echo'results'reply :: ((Untyped.ReadCtx m msg)
                               ,(Classes.FromPtr msg (Basics.Text msg))) => (Echo'echo'results msg) -> (m (Basics.Text msg))
get_Echo'echo'results'reply (Echo'echo'results'newtype_ struct) = (do
    ptr <- (Untyped.getPtr 0 struct)
    (Classes.fromPtr (Untyped.message struct) ptr)
    )
set_Echo'echo'results'reply :: ((Untyped.RWCtx m s)
                               ,(Classes.ToPtr s (Basics.Text (Message.Mut s)))) => (Echo'echo'results (Message.Mut s)) -> (Basics.Text (Message.Mut s)) -> (m ())
set_Echo'echo'results'reply (Echo'echo'results'newtype_ struct) value = (do
    ptr <- (Classes.toPtr (Untyped.message struct) value)
    (Untyped.setPtr ptr 0 struct)
    )
has_Echo'echo'results'reply :: ((Untyped.ReadCtx m msg)) => (Echo'echo'results msg) -> (m Std_.Bool)
has_Echo'echo'results'reply (Echo'echo'results'newtype_ struct) = (Std_.isJust <$> (Untyped.getPtr 0 struct))
new_Echo'echo'results'reply :: ((Untyped.RWCtx m s)) => Std_.Int -> (Echo'echo'results (Message.Mut s)) -> (m (Basics.Text (Message.Mut s)))
new_Echo'echo'results'reply len struct = (do
    result <- (Basics.newText (Untyped.message struct) len)
    (set_Echo'echo'results'reply struct result)
    (Std_.pure result)
    )