    {-# LANGUAGE CPP                #-}
    {-# LANGUAGE DeriveAnyClass     #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveGeneric      #-}
    {-# LANGUAGE FlexibleInstances  #-}

    -- | Shared types.

    module Xeno.Types where

    import Control.DeepSeq
    import Control.Exception
    import Data.ByteString.Char8 (ByteString, pack)
    import Data.Data
    import GHC.Generics

    #if MIN_VERSION_base(4,9,0)
    import Control.Monad.Fail

    -- It is recommended to use more specific `failHere` instead
    instance MonadFail (Either Xeno.Types.XenoException) where
      fail :: forall a. String -> Either XenoException a
    fail = XenoException -> Either XenoException a
    forall a b. a -> Either a b
    Left (XenoException -> Either XenoException a)
    -> (String -> XenoException) -> String -> Either XenoException a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> ByteString -> XenoException
    XenoParseError Int
    0 (ByteString -> XenoException)
    -> (String -> ByteString) -> String -> XenoException
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> ByteString
    pack
    #endif

    data XenoException
      = XenoStringIndexProblem { XenoException -> Int
    stringIndex :: Int, XenoException -> ByteString
    inputString :: ByteString }
      | XenoParseError         { XenoException -> Int
    inputIndex  :: Int, XenoException -> ByteString
    message     :: ByteString }
      | XenoExpectRootNode
      deriving (Int -> XenoException -> ShowS
    [XenoException] -> ShowS
    XenoException -> String
    (Int -> XenoException -> ShowS)
    -> (XenoException -> String)
    -> ([XenoException] -> ShowS)
    -> Show XenoException
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> XenoException -> ShowS
    showsPrec :: Int -> XenoException -> ShowS
    $cshow :: XenoException -> String
    show :: XenoException -> String
    $cshowList :: [XenoException] -> ShowS
    showList :: [XenoException] -> ShowS
    Show, Typeable XenoException
    Typeable XenoException =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> XenoException -> c XenoException)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c XenoException)
    -> (XenoException -> Constr)
    -> (XenoException -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c XenoException))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c XenoException))
    -> ((forall b. Data b => b -> b) -> XenoException -> XenoException)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> XenoException -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> XenoException -> r)
    -> (forall u. (forall d. Data d => d -> u) -> XenoException -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> XenoException -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> XenoException -> m XenoException)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> XenoException -> m XenoException)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> XenoException -> m XenoException)
    -> Data XenoException
    XenoException -> Constr
    XenoException -> DataType
    (forall b. Data b => b -> b) -> XenoException -> XenoException
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> XenoException -> u
    forall u. (forall d. Data d => d -> u) -> XenoException -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> XenoException -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> XenoException -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> XenoException -> m XenoException
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XenoException -> m XenoException
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c XenoException
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> XenoException -> c XenoException
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c XenoException)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c XenoException)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> XenoException -> c XenoException
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> XenoException -> c XenoException
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c XenoException
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c XenoException
    $ctoConstr :: XenoException -> Constr
    toConstr :: XenoException -> Constr
    $cdataTypeOf :: XenoException -> DataType
    dataTypeOf :: XenoException -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c XenoException)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c XenoException)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c XenoException)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c XenoException)
    $cgmapT :: (forall b. Data b => b -> b) -> XenoException -> XenoException
    gmapT :: (forall b. Data b => b -> b) -> XenoException -> XenoException
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> XenoException -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> XenoException -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> XenoException -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> XenoException -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> XenoException -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> XenoException -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> XenoException -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> XenoException -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> XenoException -> m XenoException
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> XenoException -> m XenoException
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XenoException -> m XenoException
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XenoException -> m XenoException
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XenoException -> m XenoException
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XenoException -> m XenoException
    Data, Typeable, XenoException -> ()
    (XenoException -> ()) -> NFData XenoException
    forall a. (a -> ()) -> NFData a
    $crnf :: XenoException -> ()
    rnf :: XenoException -> ()
    NFData, (forall x. XenoException -> Rep XenoException x)
    -> (forall x. Rep XenoException x -> XenoException)
    -> Generic XenoException
    forall x. Rep XenoException x -> XenoException
    forall x. XenoException -> Rep XenoException x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. XenoException -> Rep XenoException x
    from :: forall x. XenoException -> Rep XenoException x
    $cto :: forall x. Rep XenoException x -> XenoException
    to :: forall x. Rep XenoException x -> XenoException
    Generic)

    instance Exception XenoException where displayException :: XenoException -> String
    displayException = XenoException -> String
    forall a. Show a => a -> String
    show

    -- | ByteString wich guaranted have '\NUL' at the end
    newtype ByteStringZeroTerminated = BSZT ByteString deriving ((forall x.
     ByteStringZeroTerminated -> Rep ByteStringZeroTerminated x)
    -> (forall x.
        Rep ByteStringZeroTerminated x -> ByteStringZeroTerminated)
    -> Generic ByteStringZeroTerminated
    forall x.
    Rep ByteStringZeroTerminated x -> ByteStringZeroTerminated
    forall x.
    ByteStringZeroTerminated -> Rep ByteStringZeroTerminated x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x.
    ByteStringZeroTerminated -> Rep ByteStringZeroTerminated x
    from :: forall x.
    ByteStringZeroTerminated -> Rep ByteStringZeroTerminated x
    $cto :: forall x.
    Rep ByteStringZeroTerminated x -> ByteStringZeroTerminated
    to :: forall x.
    Rep ByteStringZeroTerminated x -> ByteStringZeroTerminated
    Generic, ByteStringZeroTerminated -> ()
    (ByteStringZeroTerminated -> ()) -> NFData ByteStringZeroTerminated
    forall a. (a -> ()) -> NFData a
    $crnf :: ByteStringZeroTerminated -> ()
    rnf :: ByteStringZeroTerminated -> ()
    NFData)