{-# LANGUAGE Safe #-}
{-# LANGUAGE TypeFamilies, AllowAmbiguousTypes, FlexibleInstances, FlexibleContexts #-}
module Text.Gigaparsec.Errors.ErrorBuilder (ErrorBuilder(..), Token(..)) where
import Text.Gigaparsec.Errors.DefaultErrorBuilder ( StringBuilder, buildDefault
, vanillaErrorDefault, specialisedErrorDefault
, rawDefault, namedDefault, endOfInputDefault
, expectedDefault, unexpectedDefault
, disjunct, combineMessagesDefault
, posDefault, lineInfoDefault
)
import {-# SOURCE #-} Text.Gigaparsec.Errors.TokenExtractors (Token(Named, Raw), tillNextWhitespace)
import Data.Char (isSpace)
import Data.Kind (Constraint)
import Data.List.NonEmpty (NonEmpty)
import Data.Set (Set)
import Data.Set qualified as Set (toList)
import Data.String (IsString(fromString))
import Data.Void (Void)
type ErrorBuilder :: * -> Constraint
class Ord (Item err) => ErrorBuilder err where
build :: Position err
-> Source err
-> ErrorInfoLines err
-> err
type Position err
type Source err
pos :: Word
-> Word
-> Position err
source :: Maybe FilePath
-> Source err
type ErrorInfoLines err
vanillaError :: UnexpectedLine err
-> ExpectedLine err
-> Messages err
-> LineInfo err
-> ErrorInfoLines err
specialisedError :: Messages err
-> LineInfo err
-> ErrorInfoLines err
type ExpectedItems err
type Messages err
combineExpectedItems :: Set (Item err)
-> ExpectedItems err
combineMessages :: [Message err]
-> Messages err
type UnexpectedLine err
type ExpectedLine err
type Message err
type LineInfo err
unexpected :: Maybe (Item err)
-> UnexpectedLine err
expected :: ExpectedItems err
-> ExpectedLine err
reason :: String
-> Message err
message :: String
-> Message err
lineInfo :: String
-> [String]
-> [String]
-> Word
-> Word
-> Word
-> LineInfo err
numLinesBefore :: Int
numLinesAfter :: Int
type Item err
raw :: String
-> Item err
named :: String
-> Item err
endOfInput :: Item err
unexpectedToken :: NonEmpty Char
-> Word
-> Bool
-> Token
instance ErrorBuilder String where
{-# INLINE build #-}
build :: Position String -> Source String -> ErrorInfoLines String -> String
build = StringBuilder -> Maybe StringBuilder -> [StringBuilder] -> String
Position String -> Source String -> ErrorInfoLines String -> String
buildDefault
type Position String = StringBuilder
type Source String = Maybe StringBuilder
{-# INLINE pos #-}
pos :: Word -> Word -> Position String
pos = Word -> Word -> StringBuilder
Word -> Word -> Position String
posDefault
{-# INLINE source #-}
source :: Maybe String -> Source String
source = (String -> StringBuilder) -> Maybe String -> Maybe StringBuilder
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> StringBuilder
forall a. IsString a => String -> a
fromString
type ErrorInfoLines String = [StringBuilder]
{-# INLINE vanillaError #-}
vanillaError :: UnexpectedLine String
-> ExpectedLine String
-> Messages String
-> LineInfo String
-> ErrorInfoLines String
vanillaError = Maybe StringBuilder
-> Maybe StringBuilder
-> [StringBuilder]
-> [StringBuilder]
-> [StringBuilder]
UnexpectedLine String
-> ExpectedLine String
-> Messages String
-> LineInfo String
-> ErrorInfoLines String
forall (t :: * -> *).
Foldable t =>
Maybe StringBuilder
-> Maybe StringBuilder
-> t StringBuilder
-> [StringBuilder]
-> [StringBuilder]
vanillaErrorDefault
{-# INLINE specialisedError #-}
specialisedError :: Messages String -> LineInfo String -> ErrorInfoLines String
specialisedError = [StringBuilder] -> [StringBuilder] -> [StringBuilder]
Messages String -> LineInfo String -> ErrorInfoLines String
specialisedErrorDefault
type ExpectedItems String = Maybe StringBuilder
type Messages String = [StringBuilder]
{-# INLINE combineExpectedItems #-}
combineExpectedItems :: Set (Item String) -> ExpectedItems String
combineExpectedItems = Bool -> [String] -> Maybe StringBuilder
disjunct Bool
True ([String] -> Maybe StringBuilder)
-> (Set String -> [String]) -> Set String -> Maybe StringBuilder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set String -> [String]
forall a. Set a -> [a]
Set.toList
{-# INLINE combineMessages #-}
combineMessages :: [Message String] -> Messages String
combineMessages = [String] -> [StringBuilder]
[Message String] -> Messages String
forall (t :: * -> *). Foldable t => t String -> [StringBuilder]
combineMessagesDefault
type UnexpectedLine String = Maybe StringBuilder
type ExpectedLine String = Maybe StringBuilder
type Message String = String
type LineInfo String = [StringBuilder]
{-# INLINE unexpected #-}
unexpected :: Maybe (Item String) -> UnexpectedLine String
unexpected = Maybe String -> Maybe StringBuilder
Maybe (Item String) -> UnexpectedLine String
unexpectedDefault
{-# INLINE expected #-}
expected :: ExpectedItems String -> ExpectedLine String
expected = Maybe StringBuilder -> Maybe StringBuilder
ExpectedItems String -> ExpectedLine String
expectedDefault
{-# INLINE reason #-}
reason :: String -> Message String
reason = String -> String
String -> Message String
forall a. a -> a
id
{-# INLINE message #-}
message :: String -> Message String
message = String -> String
String -> Message String
forall a. a -> a
id
{-# INLINE lineInfo #-}
lineInfo :: String
-> [String] -> [String] -> Word -> Word -> Word -> LineInfo String
lineInfo = String
-> [String] -> [String] -> Word -> Word -> Word -> [StringBuilder]
String
-> [String] -> [String] -> Word -> Word -> Word -> LineInfo String
lineInfoDefault
{-# INLINE numLinesBefore #-}
numLinesBefore :: Int
numLinesBefore = Int
1
{-# INLINE numLinesAfter #-}
numLinesAfter :: Int
numLinesAfter = Int
1
type Item String = String
{-# INLINE raw #-}
raw :: String -> Item String
raw = String -> String
String -> Item String
rawDefault
{-# INLINE named #-}
named :: String -> Item String
named = String -> String
String -> Item String
namedDefault
{-# INLINE endOfInput #-}
endOfInput :: Item String
endOfInput = String
Item String
endOfInputDefault
{-# INLINABLE unexpectedToken #-}
unexpectedToken :: NonEmpty Char -> Word -> Bool -> Token
unexpectedToken = Bool -> (Char -> Bool) -> NonEmpty Char -> Word -> Bool -> Token
tillNextWhitespace Bool
True Char -> Bool
isSpace
instance ErrorBuilder () where
build :: Position () -> Source () -> ErrorInfoLines () -> ()
build Position ()
_ Source ()
_ ErrorInfoLines ()
_ = ()
type Position () = ()
type Source () = ()
type ErrorInfoLines () = ()
type ExpectedItems () = ()
type Messages () = ()
type UnexpectedLine () = ()
type ExpectedLine () = ()
type Message () = ()
type LineInfo () = ()
type Item () = ()
pos :: Word -> Word -> Position ()
pos = Word -> Word -> ()
Word -> Word -> Position ()
forall a. HasCallStack => a
undefined
source :: Maybe String -> Source ()
source = Maybe String -> ()
Maybe String -> Source ()
forall a. HasCallStack => a
undefined
vanillaError :: UnexpectedLine ()
-> ExpectedLine ()
-> Messages ()
-> LineInfo ()
-> ErrorInfoLines ()
vanillaError = () -> () -> () -> () -> ()
UnexpectedLine ()
-> ExpectedLine ()
-> Messages ()
-> LineInfo ()
-> ErrorInfoLines ()
forall a. HasCallStack => a
undefined
specialisedError :: Messages () -> LineInfo () -> ErrorInfoLines ()
specialisedError = () -> () -> ()
Messages () -> LineInfo () -> ErrorInfoLines ()
forall a. HasCallStack => a
undefined
combineExpectedItems :: Set (Item ()) -> ExpectedItems ()
combineExpectedItems = Set () -> ()
Set (Item ()) -> ExpectedItems ()
forall a. HasCallStack => a
undefined
combineMessages :: [Message ()] -> Messages ()
combineMessages = [()] -> ()
[Message ()] -> Messages ()
forall a. HasCallStack => a
undefined
unexpected :: Maybe (Item ()) -> UnexpectedLine ()
unexpected = Maybe () -> ()
Maybe (Item ()) -> UnexpectedLine ()
forall a. HasCallStack => a
undefined
expected :: ExpectedItems () -> ExpectedLine ()
expected = () -> ()
ExpectedItems () -> ExpectedLine ()
forall a. HasCallStack => a
undefined
reason :: String -> Message ()
reason = String -> ()
String -> Message ()
forall a. HasCallStack => a
undefined
message :: String -> Message ()
message = String -> ()
String -> Message ()
forall a. HasCallStack => a
undefined
lineInfo :: String
-> [String] -> [String] -> Word -> Word -> Word -> LineInfo ()
lineInfo = String -> [String] -> [String] -> Word -> Word -> Word -> ()
String
-> [String] -> [String] -> Word -> Word -> Word -> LineInfo ()
forall a. HasCallStack => a
undefined
numLinesBefore :: Int
numLinesBefore = Int
forall a. HasCallStack => a
undefined
numLinesAfter :: Int
numLinesAfter = Int
forall a. HasCallStack => a
undefined
raw :: String -> Item ()
raw = String -> ()
String -> Item ()
forall a. HasCallStack => a
undefined
named :: String -> Item ()
named = String -> ()
String -> Item ()
forall a. HasCallStack => a
undefined
endOfInput :: Item ()
endOfInput = ()
Item ()
forall a. HasCallStack => a
undefined
unexpectedToken :: NonEmpty Char -> Word -> Bool -> Token
unexpectedToken = NonEmpty Char -> Word -> Bool -> Token
forall a. HasCallStack => a
undefined
instance ErrorBuilder Void where
build :: Position Void -> Source Void -> ErrorInfoLines Void -> Void
build = Void -> Void -> Void -> Void
Position Void -> Source Void -> ErrorInfoLines Void -> Void
forall a. HasCallStack => a
undefined
type Position Void = Void
type Source Void = Void
type ErrorInfoLines Void = Void
type ExpectedItems Void = Void
type Messages Void = Void
type UnexpectedLine Void = Void
type ExpectedLine Void = Void
type Message Void = Void
type LineInfo Void = Void
type Item Void = Void
pos :: Word -> Word -> Position Void
pos = Word -> Word -> Void
Word -> Word -> Position Void
forall a. HasCallStack => a
undefined
source :: Maybe String -> Source Void
source = Maybe String -> Void
Maybe String -> Source Void
forall a. HasCallStack => a
undefined
vanillaError :: UnexpectedLine Void
-> ExpectedLine Void
-> Messages Void
-> LineInfo Void
-> ErrorInfoLines Void
vanillaError = Void -> Void -> Void -> Void -> Void
UnexpectedLine Void
-> ExpectedLine Void
-> Messages Void
-> LineInfo Void
-> ErrorInfoLines Void
forall a. HasCallStack => a
undefined
specialisedError :: Messages Void -> LineInfo Void -> ErrorInfoLines Void
specialisedError = Void -> Void -> Void
Messages Void -> LineInfo Void -> ErrorInfoLines Void
forall a. HasCallStack => a
undefined
combineExpectedItems :: Set (Item Void) -> ExpectedItems Void
combineExpectedItems = Set Void -> Void
Set (Item Void) -> ExpectedItems Void
forall a. HasCallStack => a
undefined
combineMessages :: [Message Void] -> Messages Void
combineMessages = [Void] -> Void
[Message Void] -> Messages Void
forall a. HasCallStack => a
undefined
unexpected :: Maybe (Item Void) -> UnexpectedLine Void
unexpected = Maybe Void -> Void
Maybe (Item Void) -> UnexpectedLine Void
forall a. HasCallStack => a
undefined
expected :: ExpectedItems Void -> ExpectedLine Void
expected = Void -> Void
ExpectedItems Void -> ExpectedLine Void
forall a. HasCallStack => a
undefined
reason :: String -> Message Void
reason = String -> Void
String -> Message Void
forall a. HasCallStack => a
undefined
message :: String -> Message Void
message = String -> Void
String -> Message Void
forall a. HasCallStack => a
undefined
lineInfo :: String
-> [String] -> [String] -> Word -> Word -> Word -> LineInfo Void
lineInfo = String -> [String] -> [String] -> Word -> Word -> Word -> Void
String
-> [String] -> [String] -> Word -> Word -> Word -> LineInfo Void
forall a. HasCallStack => a
undefined
numLinesBefore :: Int
numLinesBefore = Int
forall a. HasCallStack => a
undefined
numLinesAfter :: Int
numLinesAfter = Int
forall a. HasCallStack => a
undefined
raw :: String -> Item Void
raw = String -> Void
String -> Item Void
forall a. HasCallStack => a
undefined
named :: String -> Item Void
named = String -> Void
String -> Item Void
forall a. HasCallStack => a
undefined
endOfInput :: Item Void
endOfInput = Void
Item Void
forall a. HasCallStack => a
undefined
unexpectedToken :: NonEmpty Char -> Word -> Bool -> Token
unexpectedToken = NonEmpty Char -> Word -> Bool -> Token
forall a. HasCallStack => a
undefined