Created
October 3, 2013 13:54
-
-
Save qoelet/6810206 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Captain Crunch fun: serialization in Haskell using cereal ("serial, cereal... get it?") | |
-- Install: cabal install cereal | |
-- serialization | |
main = do | |
let msg = "hello cereal!" | |
cerealized = encode msg | |
writeFile "myFile" cerealized | |
-- deserialization | |
main = do | |
contents <- readFile "myFile" | |
-- either is a funny function that applies a function to the left or the right ("right, correct... get it?") | |
putStrLn ("Decereal'ed message: " ++ (either id id (decode contents))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment