pinch- An alternative implementation of Thrift for Haskell.

Copyright(c) Abhinav Gupta 2015
MaintainerAbhinav Gupta <>
Safe HaskellNone



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



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.


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 


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


MapItem !(Value k) !(Value v) 


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.


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.