Popularity
1.0
Declining
Activity
0.0
Stable
0
2
0

Monthly Downloads: 6
Programming language: Haskell
License: MIT License
Tags: System     Read    

read-io alternatives and similar packages

Based on the "read" category.
Alternatively, view read-io alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of read-io or a related project?

Add another 'read' Package

README

ReadIO - Read IO library

Hackage

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

Usage

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/a.foo:

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

and data/b.foo:

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

Read

Use

foo <- System.IO.Read.readFrom "data/a.foo" :: 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].

Show

Use

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

to serialize foo of type Foo to data/out.foo.

Credits

License

See LICENSE file.


*Note that all licence references and agreements mentioned in the read-io README section above are relevant to that project's source code only.