{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
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
instance MonadFail (Either Xeno.Types.XenoException) where
fail = Left . XenoParseError 0 . pack
#endif
data XenoException
= XenoStringIndexProblem { stringIndex :: Int, inputString :: ByteString }
| XenoParseError { inputIndex :: Int, message :: ByteString }
| XenoExpectRootNode
deriving (Show, Data, Typeable, NFData, Generic)
instance Exception XenoException where displayException = show
newtype ByteStringZeroTerminated = BSZT ByteString deriving (Generic, NFData)