Module RW.Base

This library defines the class ReadWrite which is the basis to define compact data representations for various types. Furthermore, instances of this class are defined for various standard types defined in the prelude.

Author: Lasse Züngel

Version: July 2024

Summary of exported operations:

defaultParams :: RWParameters  Deterministic 
Default RWParameters for writing compact data.
monoRWType :: String -> RWType  Deterministic 
Creates a representation of a monomorphic type.
readData :: ReadWrite a => String -> Maybe a  Deterministic 
Data reading and writing Parses a compact data representation and returns the value.
readDataFile :: ReadWrite a => String -> IO (Maybe a)  Deterministic 
Reads a file containing a compact data representation, parses the contents and returns the value.
writeDataFile :: ReadWrite a => String -> a -> IO ()  Deterministic 
Writes some data to a file containing a compact data representation.
writeDataFileP :: ReadWrite a => RWParameters -> String -> a -> IO ()  Deterministic 
Writes some data to a file containing a compact data representation and use specific RWParameters .
showData :: ReadWrite a => a -> String  Deterministic 
Converts a given data value into a compact string representation.
showDataP :: ReadWrite a => RWParameters -> a -> String  Deterministic 
Converts data to a compact string representation using specific RWParameters .

Exported datatypes:


RWParameters

Writing RWParameters .

Constructors:

  • RWParameters :: Int -> Int -> RWParameters

    Fields:

    • minStrLen :: Int
    • alphabetLen :: Int

RWType

Represents a type in the compact data representation.

Constructors:

  • RWType :: String -> [RWType] -> RWType

Exported operations:

defaultParams :: RWParameters  Deterministic 

Default RWParameters for writing compact data.

Further infos:
  • solution complete, i.e., able to compute all solutions

monoRWType :: String -> RWType  Deterministic 

Creates a representation of a monomorphic type.

Further infos:
  • solution complete, i.e., able to compute all solutions

readData :: ReadWrite a => String -> Maybe a  Deterministic 

Data reading and writing Parses a compact data representation and returns the value. If the parse failes (e.g. due to a type mismatch), Nothing is returned.

This operation might fail if the input is not well-formed.

readDataFile :: ReadWrite a => String -> IO (Maybe a)  Deterministic 

Reads a file containing a compact data representation, parses the contents and returns the value.

If the parse failes (e.g. due to a type mismatch or a bad input format), Nothing is returned.

writeDataFile :: ReadWrite a => String -> a -> IO ()  Deterministic 

Writes some data to a file containing a compact data representation.

writeDataFileP :: ReadWrite a => RWParameters -> String -> a -> IO ()  Deterministic 

Writes some data to a file containing a compact data representation and use specific RWParameters .

showData :: ReadWrite a => a -> String  Deterministic 

Converts a given data value into a compact string representation.

This is rarely what you want. Use writeDataFile if you want to write the data into a file.

showDataP :: ReadWrite a => RWParameters -> a -> String  Deterministic 

Converts data to a compact string representation using specific RWParameters .

This is rarely what you want. Use writeDataFileP if you want to write the data into a file.