readable-0.3.1: Reading from Text and ByteString
Safe HaskellSafe
LanguageHaskell98

Data.Readable

Description

The Read type class is very useful for building data types from String representations. But String has high overhead, so sometimes it isn't suitable for applications where space usage and performance are important. This library provides a simpler version of Read's functionality for Text and ByteStrings.

Synopsis

Documentation

class Readable a where Source #

ByteString and Text reading using MonadPlus to handle parse failure. On error, fromText and fromBS will return mzero. You can use mplus to provide fallback defaults.

Minimal complete definition

fromText

Methods

fromText :: MonadPlus m => Text -> m a Source #

Reads data from a Text representation.

fromBS :: MonadPlus m => ByteString -> m a Source #

Reads data from a UTF8 encoded ByteString. The default implementation of this function simply decodes with UTF-8 and then calls the fromText function. If decoding fails, mzero will be returned. You can provide your own implementation if you need different behavior such as not decoding to UTF8.

Instances

Instances details
Readable Bool Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Bool Source #

fromBS :: MonadPlus m => ByteString -> m Bool Source #

Readable Double Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Double Source #

fromBS :: MonadPlus m => ByteString -> m Double Source #

Readable Float Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Float Source #

fromBS :: MonadPlus m => ByteString -> m Float Source #

Readable Int Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Int Source #

fromBS :: MonadPlus m => ByteString -> m Int Source #

Readable Int8 Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Int8 Source #

fromBS :: MonadPlus m => ByteString -> m Int8 Source #

Readable Int16 Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Int16 Source #

fromBS :: MonadPlus m => ByteString -> m Int16 Source #

Readable Int32 Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Int32 Source #

fromBS :: MonadPlus m => ByteString -> m Int32 Source #

Readable Int64 Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Int64 Source #

fromBS :: MonadPlus m => ByteString -> m Int64 Source #

Readable Integer Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Integer Source #

fromBS :: MonadPlus m => ByteString -> m Integer Source #

Readable Word8 Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Word8 Source #

fromBS :: MonadPlus m => ByteString -> m Word8 Source #

Readable Word16 Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Word16 Source #

fromBS :: MonadPlus m => ByteString -> m Word16 Source #

Readable Word32 Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Word32 Source #

fromBS :: MonadPlus m => ByteString -> m Word32 Source #

Readable Word64 Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Word64 Source #

fromBS :: MonadPlus m => ByteString -> m Word64 Source #

Readable ByteString Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m ByteString Source #

fromBS :: MonadPlus m => ByteString -> m ByteString Source #

Readable Text Source # 
Instance details

Defined in Data.Readable

Methods

fromText :: MonadPlus m => Text -> m Text Source #

fromBS :: MonadPlus m => ByteString -> m Text Source #