packages feed

hydra-kernel-0.17.5: src/main/haskell/Hydra/Parsing.hs

-- Note: this is an automatically generated file. Do not edit.

-- | Parser combinator types for text parsing

module Hydra.Parsing where

import qualified Hydra.Core as Core
import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, lines, map, pure, sum, unlines)
import qualified Data.Scientific as Sci

-- | An error which occurred while parsing
data ParseError =
  ParseError {
    -- | An error message
    parseErrorMessage :: String,
    -- | The remaining input (as codepoints) at the point of failure
    parseErrorRemainder :: [Int]}
  deriving (Eq, Ord, Read, Show)

_ParseError = Core.Name "hydra.parsing.ParseError"

_ParseError_message = Core.Name "message"

_ParseError_remainder = Core.Name "remainder"

-- | The result of a parse operation
data ParseResult a =
  -- | A successful parse, with a value and the remaining unparsed input
  ParseResultSuccess (ParseSuccess a) |
  -- | A failed parse, with an error message and the remaining input
  ParseResultFailure ParseError
  deriving (Eq, Ord, Read, Show)

_ParseResult = Core.Name "hydra.parsing.ParseResult"

_ParseResult_success = Core.Name "success"

_ParseResult_failure = Core.Name "failure"

-- | A successful parse result
data ParseSuccess a =
  ParseSuccess {
    -- | The parsed value
    parseSuccessValue :: a,
    -- | The remaining unparsed input, as codepoints. Represented as a list rather than a string
    parseSuccessRemainder :: [Int]}
  deriving (Eq, Ord, Read, Show)

_ParseSuccess = Core.Name "hydra.parsing.ParseSuccess"

_ParseSuccess_value = Core.Name "value"

_ParseSuccess_remainder = Core.Name "remainder"

-- | A parser which consumes characters from a codepoint list and produces a value. The input is a list, rather than a string, so that consuming one character is a constant-time operation rather than a linear-time string copy.
newtype Parser a =
  Parser {
    unParser :: ([Int] -> ParseResult a)}

_Parser = Core.Name "hydra.parsing.Parser"