Skip to content

Instantly share code, notes, and snippets.

@qoelet
Created October 3, 2013 13:54
Show Gist options
  • Save qoelet/6810206 to your computer and use it in GitHub Desktop.
Save qoelet/6810206 to your computer and use it in GitHub Desktop.
-- 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