Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

High performance object serialization library supporting sum types

I wonder if any of the high performance serialization libraries (like Google protocol buffers) support sum types.

Sum types are tagged unions, basically the ability to say that something is either A, B, or C. Sum types are used in languages such as Haskell and ML which support Algebraic Data Types

like image 997
user239558 Avatar asked Feb 21 '12 14:02

user239558


2 Answers

If by "like Google protocol buffers" you mean ability to generate code for multiple languages then probably such thing doesn't exist. Emulating sum types in languages which don't support them is awkward at best (try to pattern match on boost:variant for example). So it makes sense to leave them out if main target is mainstream languages.

If you are content with using only haskell/ocaml/whatever there is plenty of choices. For haskell there are cereal, binary, safecopy and probably others. There is piqi project for ocaml.

like image 188
Shimuuar Avatar answered Oct 08 '22 20:10

Shimuuar


I'm not aware of any practical systems that support sum types other than Piqi (I'm the author). Piqi is compatible with Protocol Buffers and natively supports OCaml and Erlang. Absence of sum types in Protocol buffers was one of the reasons why I created it.

My plan is to expand Piqi to support other languages such as Haskell, Clojure, etc.

like image 33
alavrik Avatar answered Oct 08 '22 19:10

alavrik