{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
module Text.Megaparsec.State
( State (..)
, PosState (..) )
where
import Control.DeepSeq (NFData)
import Data.Data (Data)
import Data.Typeable (Typeable)
import GHC.Generics
import Text.Megaparsec.Pos
import {-# SOURCE #-} Text.Megaparsec.Error (ParseError)
data State s e = State
{ stateInput :: s
, stateOffset :: {-# UNPACK #-} !Int
, statePosState :: PosState s
, stateParseErrors :: [ParseError s e]
} deriving (Typeable, Generic)
deriving instance ( Show (ParseError s e)
, Show s
) => Show (State s e)
deriving instance ( Eq (ParseError s e)
, Eq s
) => Eq (State s e)
deriving instance ( Data e
, Data (ParseError s e)
, Data s
) => Data (State s e)
instance (NFData s, NFData (ParseError s e)) => NFData (State s e)
data PosState s = PosState
{ pstateInput :: s
, pstateOffset :: !Int
, pstateSourcePos :: !SourcePos
, pstateTabWidth :: Pos
, pstateLinePrefix :: String
} deriving (Show, Eq, Data, Typeable, Generic)
instance NFData s => NFData (PosState s)