-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed package to msgpack-rpc-conduit.
Also export a slightly smaller API.
- Loading branch information
Showing
12 changed files
with
138 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
module Network.MessagePack.Capabilities | ||
( ServerCapability (..) | ||
, ClientCapability (..) | ||
) where | ||
( ServerCapability (..) | ||
, ClientCapability (..) | ||
) where | ||
|
||
import Data.MessagePack (MessagePack) | ||
import GHC.Generics (Generic) | ||
|
||
|
||
data ServerCapability | ||
= SCapMethodList | ||
-- ^ Server supports method lists and can handle more efficient method codes | ||
-- instead of strings for names. It supports the "internal.methodList" call | ||
-- to return an ordered list of method names. The client can send an index | ||
-- in this list instead of the name itself when performing an RPC call. | ||
deriving (Eq, Generic) | ||
= SCapMethodList | ||
-- ^ Server supports method lists and can handle more efficient method codes | ||
-- instead of strings for names. It supports the "internal.methodList" call | ||
-- to return an ordered list of method names. The client can send an index | ||
-- in this list instead of the name itself when performing an RPC call. | ||
deriving (Eq, Generic) | ||
|
||
instance MessagePack ServerCapability | ||
|
||
|
||
data ClientCapability | ||
= CCapMethodList | ||
-- ^ Client supports method lists and can send more efficient method codes | ||
-- instead of strings for names. | ||
deriving (Eq, Generic) | ||
= CCapMethodList | ||
-- ^ Client supports method lists and can send more efficient method codes | ||
-- instead of strings for names. | ||
deriving (Eq, Generic) | ||
|
||
instance MessagePack ClientCapability |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE DeriveFoldable #-} | ||
{-# LANGUAGE DeriveFunctor #-} | ||
{-# LANGUAGE DeriveTraversable #-} | ||
{-# LANGUAGE Safe #-} | ||
module Network.MessagePack.Types.Result | ||
( Result (..) | ||
) where | ||
|
||
import Control.Applicative (Alternative (..), Applicative (..), (<$>), | ||
(<*>)) | ||
import Data.Foldable (Foldable) | ||
import Data.Traversable (Traversable) | ||
|
||
data Result a | ||
= Success a | ||
| Failure String | ||
deriving (Read, Show, Eq, Functor, Foldable, Traversable) | ||
|
||
instance Applicative Result where | ||
pure = Success | ||
|
||
Success f <*> x = fmap f x | ||
Failure msg <*> _ = Failure msg | ||
|
||
instance Alternative Result where | ||
empty = Failure "empty alternative" | ||
|
||
s@Success {} <|> _ = s | ||
_ <|> r = r | ||
|
||
instance Monad Result where | ||
return = Success | ||
fail = Failure | ||
|
||
Success x >>= f = f x | ||
Failure msg >>= _ = Failure msg | ||
|
||
#if (MIN_VERSION_base(4,13,0)) | ||
instance MonadFail Result where | ||
fail = Failure | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters