-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Class for reading bounded values -- -- Class for reading bounded values. @package read-bounded @version 0.1.1.2 -- | Class for reading bounded values. module Text.Read.Bounded -- | Information about a bounded read. data BoundedRead a -- | The read failed. NoRead :: BoundedRead a -- | The value was successfully read exactly, and did not have to be -- clamped to a narrower representation. ExactRead :: a -> BoundedRead a -- | The value was successfully read, but had to be clamped to a narrower -- representation because its value was too wide. ClampedRead :: a -> BoundedRead a -- | Much like the Read class, but will return (possibly) clamped -- values. -- -- Typical instances of this class will clamp against minBound and -- maxBound -- -- This class is designed to avoid inconsistency problems such as the -- following: -- --
--   >>> read "321" :: Word8
--   65
--   
--   >>> read "4321" :: Word8
--   225
--   
--   >>> read "-4" :: Word8
--   252
--   
-- -- Using this class, the results are predictable and precise: -- --
--   >>> readBounded "321" :: BoundedRead Word8
--   ClampedRead 255
--   
--   >>> readBounded "4321" :: BoundedRead Word8
--   ClampedRead 255
--   
--   >>> readBounded "-4" :: BoundedRead Word8
--   ClampedRead 0
--   
--   >>> readBounded "255" :: BoundedRead Word8
--   ExactRead 255
--   
--   >>> readBounded "6" :: BoundedRead Word8
--   ExactRead 6
--   
--   >>> readBounded "xxx" :: BoundedRead Word8
--   NoRead
--   
class ReadBounded a readBounded :: ReadBounded a => String -> BoundedRead a -- | Reads a clamped value for any integer type with the given class -- constraints. Useful for implementing a ReadBounded instance or -- avoiding one. readBoundedInteger :: (Bounded a, Read a, Integral a) => String -> BoundedRead a instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.Read.Bounded.BoundedRead a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.Read.Bounded.BoundedRead a) instance GHC.Read.Read a => GHC.Read.Read (Text.Read.Bounded.BoundedRead a) instance GHC.Show.Show a => GHC.Show.Show (Text.Read.Bounded.BoundedRead a) instance Text.Read.Bounded.ReadBounded GHC.Integer.Type.Integer instance Text.Read.Bounded.ReadBounded GHC.Types.Int instance Text.Read.Bounded.ReadBounded GHC.Int.Int8 instance Text.Read.Bounded.ReadBounded GHC.Int.Int16 instance Text.Read.Bounded.ReadBounded GHC.Int.Int32 instance Text.Read.Bounded.ReadBounded GHC.Int.Int64 instance Text.Read.Bounded.ReadBounded GHC.Types.Word instance Text.Read.Bounded.ReadBounded GHC.Word.Word8 instance Text.Read.Bounded.ReadBounded GHC.Word.Word16 instance Text.Read.Bounded.ReadBounded GHC.Word.Word32 instance Text.Read.Bounded.ReadBounded GHC.Word.Word64