haskell のcereal package example
{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveGeneric #-} module Main where import Data.Serialize import GHC.Generics data Dist = Dist { distInt :: Int, distString :: String } deriving (Generic, Show) instance Serialize Dist main :: IO () main = let bs = encode d in do print bs case ( decode bs) of Right res -> print (res :: Dist) Left str -> print str where d = Dist { distInt = 1 , distString = "hello"}
ref: