    {-# LANGUAGE DeriveDataTypeable #-}
    module Data.Encoding.Exception where

    import Control.Exception.Extensible
    import Data.Word
    import Data.Typeable
    import Control.Monad.Identity

    -- | This exception type is thrown whenever something went wrong during the
    --   encoding-process.
    data EncodingException
        = HasNoRepresentation Char	-- ^ Thrown if a specific character
    				--   is not representable in an encoding.
        deriving (EncodingException -> EncodingException -> Bool
    (EncodingException -> EncodingException -> Bool)
    -> (EncodingException -> EncodingException -> Bool)
    -> Eq EncodingException
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: EncodingException -> EncodingException -> Bool
    == :: EncodingException -> EncodingException -> Bool
    $c/= :: EncodingException -> EncodingException -> Bool
    /= :: EncodingException -> EncodingException -> Bool
    Eq,Eq EncodingException
    Eq EncodingException =>
    (EncodingException -> EncodingException -> Ordering)
    -> (EncodingException -> EncodingException -> Bool)
    -> (EncodingException -> EncodingException -> Bool)
    -> (EncodingException -> EncodingException -> Bool)
    -> (EncodingException -> EncodingException -> Bool)
    -> (EncodingException -> EncodingException -> EncodingException)
    -> (EncodingException -> EncodingException -> EncodingException)
    -> Ord EncodingException
    EncodingException -> EncodingException -> Bool
    EncodingException -> EncodingException -> Ordering
    EncodingException -> EncodingException -> EncodingException
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: EncodingException -> EncodingException -> Ordering
    compare :: EncodingException -> EncodingException -> Ordering
    $c< :: EncodingException -> EncodingException -> Bool
    < :: EncodingException -> EncodingException -> Bool
    $c<= :: EncodingException -> EncodingException -> Bool
    <= :: EncodingException -> EncodingException -> Bool
    $c> :: EncodingException -> EncodingException -> Bool
    > :: EncodingException -> EncodingException -> Bool
    $c>= :: EncodingException -> EncodingException -> Bool
    >= :: EncodingException -> EncodingException -> Bool
    $cmax :: EncodingException -> EncodingException -> EncodingException
    max :: EncodingException -> EncodingException -> EncodingException
    $cmin :: EncodingException -> EncodingException -> EncodingException
    min :: EncodingException -> EncodingException -> EncodingException
    Ord,Int -> EncodingException -> ShowS
    [EncodingException] -> ShowS
    EncodingException -> String
    (Int -> EncodingException -> ShowS)
    -> (EncodingException -> String)
    -> ([EncodingException] -> ShowS)
    -> Show EncodingException
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> EncodingException -> ShowS
    showsPrec :: Int -> EncodingException -> ShowS
    $cshow :: EncodingException -> String
    show :: EncodingException -> String
    $cshowList :: [EncodingException] -> ShowS
    showList :: [EncodingException] -> ShowS
    Show,ReadPrec [EncodingException]
    ReadPrec EncodingException
    Int -> ReadS EncodingException
    ReadS [EncodingException]
    (Int -> ReadS EncodingException)
    -> ReadS [EncodingException]
    -> ReadPrec EncodingException
    -> ReadPrec [EncodingException]
    -> Read EncodingException
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS EncodingException
    readsPrec :: Int -> ReadS EncodingException
    $creadList :: ReadS [EncodingException]
    readList :: ReadS [EncodingException]
    $creadPrec :: ReadPrec EncodingException
    readPrec :: ReadPrec EncodingException
    $creadListPrec :: ReadPrec [EncodingException]
    readListPrec :: ReadPrec [EncodingException]
    Read,Typeable)

    instance Exception EncodingException

    -- | This exception type is thrown whenever something went wrong during the
    --   decoding-process.
    data DecodingException
        = IllegalCharacter Word8	-- ^ The sequence contained an illegal
    				--   byte that couldn't be decoded.
        | UnexpectedEnd		-- ^ more bytes were needed to allow a
    				--   successfull decoding.
        | OutOfRange		-- ^ the decoded value was out of the unicode range
        | IllegalRepresentation [Word8]	-- ^ The character sequence encodes a
    					--   character, but is illegal.
        deriving (DecodingException -> DecodingException -> Bool
    (DecodingException -> DecodingException -> Bool)
    -> (DecodingException -> DecodingException -> Bool)
    -> Eq DecodingException
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: DecodingException -> DecodingException -> Bool
    == :: DecodingException -> DecodingException -> Bool
    $c/= :: DecodingException -> DecodingException -> Bool
    /= :: DecodingException -> DecodingException -> Bool
    Eq,Eq DecodingException
    Eq DecodingException =>
    (DecodingException -> DecodingException -> Ordering)
    -> (DecodingException -> DecodingException -> Bool)
    -> (DecodingException -> DecodingException -> Bool)
    -> (DecodingException -> DecodingException -> Bool)
    -> (DecodingException -> DecodingException -> Bool)
    -> (DecodingException -> DecodingException -> DecodingException)
    -> (DecodingException -> DecodingException -> DecodingException)
    -> Ord DecodingException
    DecodingException -> DecodingException -> Bool
    DecodingException -> DecodingException -> Ordering
    DecodingException -> DecodingException -> DecodingException
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: DecodingException -> DecodingException -> Ordering
    compare :: DecodingException -> DecodingException -> Ordering
    $c< :: DecodingException -> DecodingException -> Bool
    < :: DecodingException -> DecodingException -> Bool
    $c<= :: DecodingException -> DecodingException -> Bool
    <= :: DecodingException -> DecodingException -> Bool
    $c> :: DecodingException -> DecodingException -> Bool
    > :: DecodingException -> DecodingException -> Bool
    $c>= :: DecodingException -> DecodingException -> Bool
    >= :: DecodingException -> DecodingException -> Bool
    $cmax :: DecodingException -> DecodingException -> DecodingException
    max :: DecodingException -> DecodingException -> DecodingException
    $cmin :: DecodingException -> DecodingException -> DecodingException
    min :: DecodingException -> DecodingException -> DecodingException
    Ord,Int -> DecodingException -> ShowS
    [DecodingException] -> ShowS
    DecodingException -> String
    (Int -> DecodingException -> ShowS)
    -> (DecodingException -> String)
    -> ([DecodingException] -> ShowS)
    -> Show DecodingException
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> DecodingException -> ShowS
    showsPrec :: Int -> DecodingException -> ShowS
    $cshow :: DecodingException -> String
    show :: DecodingException -> String
    $cshowList :: [DecodingException] -> ShowS
    showList :: [DecodingException] -> ShowS
    Show,ReadPrec [DecodingException]
    ReadPrec DecodingException
    Int -> ReadS DecodingException
    ReadS [DecodingException]
    (Int -> ReadS DecodingException)
    -> ReadS [DecodingException]
    -> ReadPrec DecodingException
    -> ReadPrec [DecodingException]
    -> Read DecodingException
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS DecodingException
    readsPrec :: Int -> ReadS DecodingException
    $creadList :: ReadS [DecodingException]
    readList :: ReadS [DecodingException]
    $creadPrec :: ReadPrec DecodingException
    readPrec :: ReadPrec DecodingException
    $creadListPrec :: ReadPrec [DecodingException]
    readListPrec :: ReadPrec [DecodingException]
    Read,Typeable)

    instance Exception DecodingException