scfg-1.0.0: src/Data/Scfg/Types.hs
{-# LANGUAGE InstanceSigs #-}
-- | Core types for the scfg configuration file format.
module Data.Scfg.Types (
Directive (..),
Config,
ParseError (..),
) where
import Control.Exception (Exception (..))
import Data.Text (Text)
import qualified Data.Text as T
{- | A directive: a name, zero or more parameteres, and zero or more
child directives.
-}
data Directive = Directive
{ directiveName :: Text
, directiveParams :: [Text]
, directiveChildren :: [Directive]
}
deriving (Show, Eq)
-- | A parsed scfg configuration: a list of top-level directives.
type Config = [Directive]
-- | An error that occurred while parsing a scfg configuration.
data ParseError = ParseError
{ errorLine :: Int
-- ^ Line number of parse error
, errorColumn :: Int
-- ^ Column number of parse error
, errorMessage :: Text
-- ^ Human-readable error message describing the parse error
}
deriving (Show, Eq)
instance Exception ParseError where
displayException :: ParseError -> String
displayException = T.unpack . errorMessage