Copyright | (c) Abhinav Gupta 2015 |
---|---|
License | BSD3 |
Maintainer | Abhinav Gupta <mail@abhinavg.net> |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
This module defines an intermediate representation for Thrift values and functions to work with the intermediate representation.
Synopsis
- data Value a where
- VBool :: !Bool -> Value TBool
- VByte :: !Int8 -> Value TByte
- VDouble :: !Double -> Value TDouble
- VInt16 :: !Int16 -> Value TInt16
- VInt32 :: !Int32 -> Value TInt32
- VInt64 :: !Int64 -> Value TInt64
- VBinary :: !ByteString -> Value TBinary
- VStruct :: !(HashMap Int16 SomeValue) -> Value TStruct
- VMap :: forall k v. (IsTType k, IsTType v) => !(FoldList (MapItem k v)) -> Value TMap
- VNullMap :: Value TMap
- VSet :: forall a. IsTType a => !(FoldList (Value a)) -> Value TSet
- VList :: forall a. IsTType a => !(FoldList (Value a)) -> Value TList
- data MapItem k v = MapItem !(Value k) !(Value v)
- data SomeValue where
- castValue :: forall a b. (IsTType a, IsTType b) => Value a -> Maybe (Value b)
- valueTType :: IsTType a => Value a -> TType a
Documentation
Value
maps directly to serialized representation of Thrift types. It
contains about as much information as what gets sent over the wire.
Value
objects are tagged with different TType
values to indicate the
type of the value.
Typical usage will not involve accessing the constructors for this type.
Pinchable
must be used to construct Value
objects or
convert them back to original types.
VBool :: !Bool -> Value TBool | |
VByte :: !Int8 -> Value TByte | |
VDouble :: !Double -> Value TDouble | |
VInt16 :: !Int16 -> Value TInt16 | |
VInt32 :: !Int32 -> Value TInt32 | |
VInt64 :: !Int64 -> Value TInt64 | |
VBinary :: !ByteString -> Value TBinary | |
VStruct :: !(HashMap Int16 SomeValue) -> Value TStruct | |
VMap :: forall k v. (IsTType k, IsTType v) => !(FoldList (MapItem k v)) -> Value TMap | |
VNullMap :: Value TMap | |
VSet :: forall a. IsTType a => !(FoldList (Value a)) -> Value TSet | |
VList :: forall a. IsTType a => !(FoldList (Value a)) -> Value TList |
A single item in a map
SomeValue
holds any value, regardless of type. This may be used when
the type of the value is not necessarily known at compile time. Typically,
this will be pattern matched on and code that depends on the value's
TType
will go inside the scope of the match.