Object serialization: Difference between revisions

Content added Content deleted
No edit summary
Line 990: Line 990:
Example uses [https://hackage.haskell.org/package/binary <tt>binary</tt>] package. Since Haskell doesn't directly support OO-style inheritance, we use a sum type instead:
Example uses [https://hackage.haskell.org/package/binary <tt>binary</tt>] package. Since Haskell doesn't directly support OO-style inheritance, we use a sum type instead:


<lang haskell>
<lang haskell>{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveGeneric #-}


module Main (main) where
module Main (main) where
Line 1,015: Line 1,014:
bytes <- ByteString.readFile "objects.dat"
bytes <- ByteString.readFile "objects.dat"
let employees = Binary.decode bytes
let employees = Binary.decode bytes
print (employees :: [Employee])
print (employees :: [Employee])</lang>
</lang>


=={{header|Groovy}}==
=={{header|Groovy}}==