Skip to content

Instantly share code, notes, and snippets.

@mxswd
Created November 28, 2013 11:07
Show Gist options
  • Save mxswd/7690281 to your computer and use it in GitHub Desktop.
Save mxswd/7690281 to your computer and use it in GitHub Desktop.
class (Show a, Read a) => PlainTextDB a where
get :: IO a
get = fmap read $ readFile "db.txt"
set :: a -> IO ()
set x = return (show x) >>= writeFile "db.txt"
instance PlainTextDB Int
main = do
set (4 :: Int)
(get :: IO Int) >>= putStrLn . show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment