pinch-0.3.0.1: An alternative implementation of Thrift for Haskell.

Copyright(c) Abhinav Gupta 2015
LicenseBSD3
MaintainerAbhinav Gupta <mail@abhinavg.net>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Pinch.Internal.Value

Description

This module defines an intermediate representation for Thrift values and functions to work with the intermediate representation.

Synopsis

Documentation

data Value a where Source

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.

Constructors

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 

Instances

Eq (Value a) 
Show (Value a) 
NFData (Value a) 
Hashable (Value a) 
IsTType a => Pinchable (Value a) 
type Tag (Value a) = a 

data MapItem k v Source

A single item in a map

Constructors

MapItem !(Value k) !(Value v) 

Instances

Eq (MapItem k v) 
Show (MapItem k v) 
NFData (MapItem k v) 
Hashable (MapItem k v) 

data SomeValue where Source

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.

Constructors

SomeValue :: IsTType a => !(Value a) -> SomeValue 

castValue :: forall a b. (IsTType a, IsTType b) => Value a -> Maybe (Value b) Source

Safely attempt to cast a Value into another.

valueTType :: IsTType a => Value a -> TType a Source

Get the TType of a Value.