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 #

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 #

Reads data from a Text representation.

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

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

Readable Bool # 

Methods

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

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

Readable Double # 

Methods

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

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

Readable Float # 

Methods

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

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

Readable Int # 

Methods

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

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

Readable Int8 # 

Methods

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

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

Readable Int16 # 

Methods

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

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

Readable Int32 # 

Methods

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

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

Readable Int64 # 

Methods

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

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

Readable Integer # 

Methods

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

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

Readable Word8 # 

Methods

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

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

Readable Word16 # 

Methods

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

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

Readable Word32 # 

Methods

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

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

Readable Word64 # 

Methods

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

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

Readable ByteString # 

Methods

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

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

Readable Text # 

Methods

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

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