Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module defines classes which are shared by the encoding and decoding modules.
Synopsis
- class ProtoEnum a where
- toProtoEnumMay :: Int32 -> Maybe a
- fromProtoEnum :: a -> Int32
Documentation
class ProtoEnum a where Source #
Similar to Enum
, but allows gaps in the sequence of numeric codes,
and uses Int32
in order to match the proto3 specification.
Absent gaps, you can use an automatic derivation of Bounded
and Enum
,
then use the default implementations for all methods of this class. But
if gaps are involved, then you must instantiate this class directly and
supply the specific numeric codes desired for each constructor.
Nothing
toProtoEnumMay :: Int32 -> Maybe a Source #
Default implementation: toEnumMay
.
toProtoEnumMay :: (Bounded a, Enum a) => Int32 -> Maybe a Source #
Default implementation: toEnumMay
.
fromProtoEnum :: a -> Int32 Source #
Default implementation: fromEnum
.
fromProtoEnum :: Enum a => a -> Int32 Source #
Default implementation: fromEnum
.