Read IO library

Latest on Hackage:

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

MIT licensed by Firas Zaidan
Maintained by

ReadIO - Read IO library


A lightweight library to read and write data types deriving Read and Show.


Defining your data types

Define your data type deriving Read and Show:

data Foo = Foo 
  { id :: Integer,
    name :: String,
    value :: Double,
    nested :: [(String, Bar)]
  deriving (Read, Show, Eq) 

data Bar = Bar 
  { some :: Char
  deriving (Read, Show, Eq) 

Creating your data files

Create some data files you want to read - e. g. data/

Foo {
  id = 0,
  name = "a",
  value = 1.5,
  nested = [
    ("key 1", Bar { some = 'a'}),
    ("key 2", Bar { some = 'A'})

and data/

Foo {
  id = 1,
  name = "b",
  value = 3.1234567800009,
  nested = [
  ("key 1", Bar { some = 'b'}),
  ("key 2", Bar { some = 'B'})



foo <- System.IO.Read.readFrom "data/" :: IO Foo

to deserialize it to IO Foo or

foos <- System.IO.Read.readDirectory "data"` :: IO [Foo]

to deserialize all containing files to IO [Foo].



System.IO.Show.showFile foo "data/"

to serialize foo of type Foo to data/



See LICENSE file.

Used by 1 package:
comments powered byDisqus