ribosome-0.9.9.9: Neovim plugin framework for Polysemy
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ribosome.Msgpack

Description

Tools for writing instances of MsgpackDecode.

Synopsis

Documentation

pattern Msgpack :: MsgpackDecode a => a -> Object #

Pattern synonym for decoding an Object.

class MsgpackDecode a where #

Class of values that can be decoded from MessagePack Objects.

Minimal complete definition

Nothing

Methods

fromMsgpack :: Object -> Either DecodeError a #

Decode a value from a MessagePack Object.

The default implementation uses generic derivation.

Instances

Instances details
MsgpackDecode Int64 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode ByteString 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode Object 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode MicroSeconds 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode MilliSeconds 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode NanoSeconds 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode Seconds 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode SimpleMode Source # 
Instance details

Defined in Ribosome.Api.Mode

MsgpackDecode MappingId Source # 
Instance details

Defined in Ribosome.Data.Mapping

MsgpackDecode NvimMode Source # 
Instance details

Defined in Ribosome.Data.Mode

MsgpackDecode Register Source # 
Instance details

Defined in Ribosome.Data.Register

MsgpackDecode RegisterType Source # 
Instance details

Defined in Ribosome.Data.RegisterType

MsgpackDecode ScratchId Source # 
Instance details

Defined in Ribosome.Data.ScratchId

MsgpackDecode WindowConfig Source # 
Instance details

Defined in Ribosome.Data.WindowConfig

MsgpackDecode PartialWindowView Source # 
Instance details

Defined in Ribosome.Data.WindowView

MsgpackDecode WindowView Source # 
Instance details

Defined in Ribosome.Data.WindowView

MsgpackDecode Buffer 
Instance details

Defined in Ribosome.Host.Api.Data

MsgpackDecode Tabpage 
Instance details

Defined in Ribosome.Host.Api.Data

MsgpackDecode Window 
Instance details

Defined in Ribosome.Host.Api.Data

MsgpackDecode DecodeError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode FieldError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode ValidUtf8 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode ValidUtf8String 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode ApiInfo 
Instance details

Defined in Ribosome.Host.Data.ApiInfo

MsgpackDecode ExtType 
Instance details

Defined in Ribosome.Host.Data.ApiInfo

MsgpackDecode ExtTypeMeta 
Instance details

Defined in Ribosome.Host.Data.ApiInfo

MsgpackDecode RpcDecl 
Instance details

Defined in Ribosome.Host.Data.ApiInfo

MsgpackDecode ApiType 
Instance details

Defined in Ribosome.Host.Data.ApiType

MsgpackDecode Bang 
Instance details

Defined in Ribosome.Host.Data.Bang

MsgpackDecode Bar 
Instance details

Defined in Ribosome.Host.Data.Bar

MsgpackDecode ChannelId 
Instance details

Defined in Ribosome.Host.Data.ChannelId

MsgpackDecode CommandMods 
Instance details

Defined in Ribosome.Host.Data.CommandMods

MsgpackDecode CommandRegister 
Instance details

Defined in Ribosome.Host.Data.CommandRegister

MsgpackDecode EventName 
Instance details

Defined in Ribosome.Host.Data.Event

MsgpackDecode Execution 
Instance details

Defined in Ribosome.Host.Data.Execution

MsgpackDecode LuaRef 
Instance details

Defined in Ribosome.Host.Data.LuaRef

MsgpackDecode RequestId 
Instance details

Defined in Ribosome.Host.Data.Request

MsgpackDecode RpcMethod 
Instance details

Defined in Ribosome.Host.Data.Request

MsgpackDecode RpcError 
Instance details

Defined in Ribosome.Host.Data.RpcError

MsgpackDecode RpcMessage 
Instance details

Defined in Ribosome.Host.Data.RpcMessage

MsgpackDecode AutocmdBuffer 
Instance details

Defined in Ribosome.Host.Data.RpcType

MsgpackDecode AutocmdEvents 
Instance details

Defined in Ribosome.Host.Data.RpcType

MsgpackDecode AutocmdGroup 
Instance details

Defined in Ribosome.Host.Data.RpcType

MsgpackDecode AutocmdId 
Instance details

Defined in Ribosome.Host.Data.RpcType

MsgpackDecode AutocmdPatterns 
Instance details

Defined in Ribosome.Host.Data.RpcType

MsgpackDecode Text 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode String 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode Integer 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode () 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode Bool 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode Char 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode Double 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode Float 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackDecode Int 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

Typeable style => MsgpackDecode (Range style) 
Instance details

Defined in Ribosome.Host.Data.Range

MsgpackDecode a => MsgpackDecode (Maybe a) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

(Typeable a, MsgpackDecode a) => MsgpackDecode [a] 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

(MsgpackDecode a, MsgpackDecode b) => MsgpackDecode (Either a b) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

(Ord k, Typeable k, Typeable v, MsgpackDecode k, MsgpackDecode v) => MsgpackDecode (Map k v) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

(Typeable b, Typeable t, DecodePath b t) => MsgpackDecode (Path b t) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

(Typeable a, Typeable b, MsgpackDecode a, MsgpackDecode b) => MsgpackDecode (a, b) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

Methods

fromMsgpack :: Object -> Either DecodeError (a, b) #

(Typeable a, Typeable b, Typeable c, MsgpackDecode a, MsgpackDecode b, MsgpackDecode c) => MsgpackDecode (a, b, c) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

Methods

fromMsgpack :: Object -> Either DecodeError (a, b, c) #

(Typeable a, Typeable b, Typeable c, Typeable d, MsgpackDecode a, MsgpackDecode b, MsgpackDecode c, MsgpackDecode d) => MsgpackDecode (a, b, c, d) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

Methods

fromMsgpack :: Object -> Either DecodeError (a, b, c, d) #

(Typeable a, Typeable b, Typeable c, Typeable d, Typeable e, MsgpackDecode a, MsgpackDecode b, MsgpackDecode c, MsgpackDecode d, MsgpackDecode e) => MsgpackDecode (a, b, c, d, e) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

Methods

fromMsgpack :: Object -> Either DecodeError (a, b, c, d, e) #

(Typeable a, Typeable b, Typeable c, Typeable d, Typeable e, Typeable f, MsgpackDecode a, MsgpackDecode b, MsgpackDecode c, MsgpackDecode d, MsgpackDecode e, MsgpackDecode f) => MsgpackDecode (a, b, c, d, e, f) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

Methods

fromMsgpack :: Object -> Either DecodeError (a, b, c, d, e, f) #

(Typeable a, Typeable b, Typeable c, Typeable d, Typeable e, Typeable f, Typeable g, MsgpackDecode a, MsgpackDecode b, MsgpackDecode c, MsgpackDecode d, MsgpackDecode e, MsgpackDecode f, MsgpackDecode g) => MsgpackDecode (a, b, c, d, e, f, g) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

Methods

fromMsgpack :: Object -> Either DecodeError (a, b, c, d, e, f, g) #

class MissingKey a where #

This class decides what to return when a key in an ObjectMap is missing for a corresponding record field.

Primarily used for Maybe fields, since they should decode to Nothing when the key is absent.

Methods

missingKey :: String -> Map String Object -> Either FieldError a #

Return a fallback value for a missing key in an ObjectMap.

Instances

Instances details
MissingKey a 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MissingKey (Maybe a) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

class MsgpackEncode a where #

Class of values that can be encoded to MessagePack Objects.

Minimal complete definition

Nothing

Methods

toMsgpack :: a -> Object #

Encode a value to MessagePack.

The default implementation uses generic derivation.

Instances

Instances details
MsgpackEncode Int64 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Int64 -> Object #

MsgpackEncode ByteString 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

MsgpackEncode Object 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Object -> Object #

MsgpackEncode MicroSeconds 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

MsgpackEncode MilliSeconds 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

MsgpackEncode NanoSeconds 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

MsgpackEncode Seconds 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Seconds -> Object #

MsgpackEncode FloatAnchor Source # 
Instance details

Defined in Ribosome.Data.FloatOptions

MsgpackEncode FloatBorder Source # 
Instance details

Defined in Ribosome.Data.FloatOptions

MsgpackEncode FloatOptions Source # 
Instance details

Defined in Ribosome.Data.FloatOptions

MsgpackEncode FloatRelative Source # 
Instance details

Defined in Ribosome.Data.FloatOptions

MsgpackEncode FloatStyle Source # 
Instance details

Defined in Ribosome.Data.FloatOptions

MsgpackEncode FloatZindex Source # 
Instance details

Defined in Ribosome.Data.FloatOptions

MsgpackEncode MappingId Source # 
Instance details

Defined in Ribosome.Data.Mapping

MsgpackEncode NvimMode Source # 
Instance details

Defined in Ribosome.Data.Mode

Methods

toMsgpack :: NvimMode -> Object #

MsgpackEncode Register Source # 
Instance details

Defined in Ribosome.Data.Register

Methods

toMsgpack :: Register -> Object #

MsgpackEncode RegisterType Source # 
Instance details

Defined in Ribosome.Data.RegisterType

MsgpackEncode ScratchId Source # 
Instance details

Defined in Ribosome.Data.ScratchId

MsgpackEncode WindowConfig Source # 
Instance details

Defined in Ribosome.Data.WindowConfig

MsgpackEncode PartialWindowView Source # 
Instance details

Defined in Ribosome.Data.WindowView

MsgpackEncode WindowView Source # 
Instance details

Defined in Ribosome.Data.WindowView

MsgpackEncode Buffer 
Instance details

Defined in Ribosome.Host.Api.Data

Methods

toMsgpack :: Buffer -> Object #

MsgpackEncode Tabpage 
Instance details

Defined in Ribosome.Host.Api.Data

Methods

toMsgpack :: Tabpage -> Object #

MsgpackEncode Window 
Instance details

Defined in Ribosome.Host.Api.Data

Methods

toMsgpack :: Window -> Object #

MsgpackEncode DecodeError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

MsgpackEncode FieldError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

MsgpackEncode ValidUtf8 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

MsgpackEncode EventName 
Instance details

Defined in Ribosome.Host.Data.Event

MsgpackEncode Execution 
Instance details

Defined in Ribosome.Host.Data.Execution

MsgpackEncode LuaRef 
Instance details

Defined in Ribosome.Host.Data.LuaRef

Methods

toMsgpack :: LuaRef -> Object #

MsgpackEncode Request 
Instance details

Defined in Ribosome.Host.Data.Request

Methods

toMsgpack :: Request -> Object #

MsgpackEncode RequestId 
Instance details

Defined in Ribosome.Host.Data.Request

MsgpackEncode RpcMethod 
Instance details

Defined in Ribosome.Host.Data.Request

MsgpackEncode RpcError 
Instance details

Defined in Ribosome.Host.Data.RpcError

Methods

toMsgpack :: RpcError -> Object #

MsgpackEncode RpcMessage 
Instance details

Defined in Ribosome.Host.Data.RpcMessage

MsgpackEncode AutocmdBuffer 
Instance details

Defined in Ribosome.Host.Data.RpcType

MsgpackEncode AutocmdEvents 
Instance details

Defined in Ribosome.Host.Data.RpcType

MsgpackEncode AutocmdGroup 
Instance details

Defined in Ribosome.Host.Data.RpcType

MsgpackEncode AutocmdId 
Instance details

Defined in Ribosome.Host.Data.RpcType

MsgpackEncode AutocmdPatterns 
Instance details

Defined in Ribosome.Host.Data.RpcType

MsgpackEncode Text 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Text -> Object #

MsgpackEncode String 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: String -> Object #

MsgpackEncode Integer 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Integer -> Object #

MsgpackEncode () 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: () -> Object #

MsgpackEncode Bool 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Bool -> Object #

MsgpackEncode Double 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Double -> Object #

MsgpackEncode Float 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Float -> Object #

MsgpackEncode Int 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Int -> Object #

MsgpackEncode a => MsgpackEncode (NonEmpty a) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: NonEmpty a -> Object #

MsgpackEncode a => MsgpackEncode (Seq a) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Seq a -> Object #

MsgpackEncode a => MsgpackEncode (Maybe a) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Maybe a -> Object #

MsgpackEncode a => MsgpackEncode [a] 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: [a] -> Object #

(MsgpackEncode k, MsgpackEncode v) => MsgpackEncode (Map k v) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Map k v -> Object #

MsgpackEncode (Path b t) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: Path b t -> Object #

(MsgpackEncode a, MsgpackEncode b) => MsgpackEncode (a, b) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: (a, b) -> Object #

(MsgpackEncode a, MsgpackEncode b, MsgpackEncode c) => MsgpackEncode (a, b, c) 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Methods

toMsgpack :: (a, b, c) -> Object #

decodeIncompatible :: Typeable a => Object -> Either DecodeError a #

Create a DecodeError for a type when the Object constructor is wrong, using Typeable to obtain the type name.

incompatible :: Typeable a => Object -> Either FieldError a #

Create a FieldError for a field when the Object constructor is wrong, using Typeable to obtain the type name.

decodeError :: Typeable a => Text -> Either DecodeError a #

Create a Left DecodeError from a Text by adding the type name via Typeable.

toDecodeError :: Typeable a => Either FieldError a -> Either DecodeError a #

Convert a FieldError in a Left to a DecodeError by adding the type name via Typeable.

renderError :: DecodeError -> Text #

Create a user-friendly message for a DecodeError.

data FieldError #

A decoding error in a field of a larger type.

May be nested arbitrarily deep.

Instances

Instances details
IsString FieldError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Error

Generic FieldError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Error

Associated Types

type Rep FieldError :: Type -> Type #

Show FieldError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Error

Eq FieldError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Error

MsgpackDecode FieldError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackEncode FieldError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

type Rep FieldError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Error

type Rep FieldError = D1 ('MetaData "FieldError" "Ribosome.Host.Class.Msgpack.Error" "ribosome-host-0.9.9.9-4n86eC1033RAA2pmC2T1m9" 'False) (C1 ('MetaCons "FieldError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "NestedFieldError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DecodeError)))

data DecodeError #

A messagepack decoding error.

Constructors

DecodeError 

Fields

Instances

Instances details
Generic DecodeError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Error

Associated Types

type Rep DecodeError :: Type -> Type #

Show DecodeError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Error

Eq DecodeError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Error

MsgpackDecode DecodeError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Decode

MsgpackEncode DecodeError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Encode

Reportable DecodeError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Error

type Rep DecodeError 
Instance details

Defined in Ribosome.Host.Class.Msgpack.Error

type Rep DecodeError = D1 ('MetaData "DecodeError" "Ribosome.Host.Class.Msgpack.Error" "ribosome-host-0.9.9.9-4n86eC1033RAA2pmC2T1m9" 'False) (C1 ('MetaCons "DecodeError" 'PrefixI 'True) (S1 ('MetaSel ('Just "mainType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "fieldError") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FieldError)))

decodeFractional :: (Read a, Fractional a, Typeable a) => Object -> Either DecodeError a #

Decode a numeric or string type using Fractional or Read.

fractionalField :: (Read a, Typeable a, Fractional a) => Object -> Either FieldError a #

Decode a numeric or string field using Fractional or Read.

decodeIntegral :: (Read a, Integral a, Typeable a) => Object -> Either DecodeError a #

Decode a numeric or string type using Integral or Read.

integralField :: (Read a, Integral a, Typeable a) => Object -> Either FieldError a #

Decode a numeric or string field using Integral or Read.

readField :: (Read a, Typeable a) => String -> Either FieldError a #

Decode a ByteString field using Read.

stringField :: (Typeable a, IsString a) => Object -> Either FieldError a #

Decode a ByteString field using IsString.

byteStringField :: Typeable a => (ByteString -> Either FieldError a) -> Object -> Either FieldError a #

Call the continuation if the Object contains a ByteString, or an error otherwise.

pattern MsgpackString :: String -> Object #

Extract a String from an Object.

msgpackMap :: MsgpackMap a => a #

Encode an arbitrary number of heterogeneously typed values to a single MessagePack map. This function is variadic, meaning that it takes an arbitrary number of arguments:

>>> msgpackMap ("number", 5 :: Int) ("status", "error" :: Text) ("intensity", 3.14 :: Double) :: Object
ObjectMap (Map.fromList [(ObjectString "number", ObjectInt 5), (ObjectString "status", ObjectString "error"), (ObjectString "intensity", ObjectFloat 3.14)])

This avoids the need to call toMsgpack once for each element and then once more for the map.

msgpackArray :: MsgpackArray a => a #

Encode an arbitrary number of heterogeneously typed values to a single MessagePack array. This function is variadic, meaning that it takes an arbitrary number of arguments:

>>> msgpackArray (5 :: Int) ("error" :: Text) (3.14 :: Double) :: Object
ObjectArray [ObjectInt 5, ObjectString "error", ObjectFloat 3.14]

This avoids the need to call toMsgpack once for each element and then once more for the array.