Idris2Doc : Data.String.Parser

Data.String.Parser

(source)
A simple parser combinator library for String. Inspired by attoparsec zepto.

Reexports

importpublic Control.Monad.Identity

Definitions

recordState : Type
  The input state, pos is position in the string and maxPos is the length of the input string.

Totality: total
Visibility: public export
Constructor: 
S : String->Int->Int->State

Projections:
.input : State->String
.maxPos : State->Int
.pos : State->Int

Hint: 
ShowState
.input : State->String
Totality: total
Visibility: public export
input : State->String
Totality: total
Visibility: public export
.pos : State->Int
Totality: total
Visibility: public export
pos : State->Int
Totality: total
Visibility: public export
.maxPos : State->Int
Totality: total
Visibility: public export
maxPos : State->Int
Totality: total
Visibility: public export
dataResult : Type->Type
  Result of applying a parser

Totality: total
Visibility: public export
Constructors:
Fail : Int->String->Resulta
OK : a->State->Resulta

Hint: 
FunctorResult
recordParseT : (Type->Type) ->Type->Type
Totality: total
Visibility: public export
Constructor: 
P : (State->m (Resulta)) ->ParseTma

Projection: 
.runParser : ParseTma->State->m (Resulta)

Hints:
Monadm=>Alternative (ParseTm)
Monadm=>Applicative (ParseTm)
Functorm=>Functor (ParseTm)
Monadm=>Monad (ParseTm)
MonadTransParseT
.runParser : ParseTma->State->m (Resulta)
Totality: total
Visibility: public export
runParser : ParseTma->State->m (Resulta)
Totality: total
Visibility: public export
Parser : Type->Type
Totality: total
Visibility: public export
parseT : Functorm=>ParseTma->String->m (EitherString (a, Int))
  Run a parser in a monad
Returns a tuple of the result and final position on success.
Returns an error message on failure.

Totality: total
Visibility: export
parse : Parsera->String->EitherString (a, Int)
  Run a parser in a pure function
Returns a tuple of the result and final position on success.
Returns an error message on failure.

Totality: total
Visibility: export
(<?>) : Functorm=>ParseTma->String->ParseTma
  Combinator that replaces the error message on failure.
This allows combinators to output relevant errors

Totality: total
Visibility: export
Fixity Declaration: infixl operator, level 0
skip : Functorm=>ParseTma->ParseTm ()
  Discards the result of a parser

Totality: total
Visibility: export
optionMap : Functorm=>b-> (a->b) ->ParseTma->ParseTmb
  Maps the result of the parser `p` or returns `def` if it fails.

Totality: total
Visibility: export
option : Functorm=>a->ParseTma->ParseTma
  Runs the result of the parser `p` or returns `def` if it fails.

Totality: total
Visibility: export
succeeds : Functorm=>ParseTma->ParseTmBool
  Returns a Bool indicating whether `p` succeeded

Totality: total
Visibility: export
optional : Functorm=>ParseTma->ParseTm (Maybea)
  Returns a Maybe that contains the result of `p` if it succeeds or `Nothing` if it fails.

Totality: total
Visibility: export
requireFailure : Functorm=>ParseTma->ParseTm ()
  Succeeds if and only if the argument parser fails.

In Parsec, this combinator is called `notFollowedBy`.

Totality: total
Visibility: export
fail : Applicativem=>String->ParseTma
  Fail with some error message

Totality: total
Visibility: export
satisfy : Applicativem=> (Char->Bool) ->ParseTmChar
  Succeeds if the next char satisfies the predicate `f`

Totality: total
Visibility: export
string : Applicativem=>String->ParseTmString
  Succeeds if the string `str` follows.

Totality: total
Visibility: export
eos : Applicativem=>ParseTm ()
  Succeeds if the end of the string is reached.

Totality: total
Visibility: export
char : Applicativem=>Char->ParseTmChar
  Succeeds if the next char is `c`

Totality: total
Visibility: export
space : Applicativem=>ParseTmChar
  Parses a space character

Totality: total
Visibility: export
alphaNum : Applicativem=>ParseTmChar
  Parses a letter or digit (a character between \'0\' and \'9\').
Returns the parsed character.

Totality: total
Visibility: export
letter : Applicativem=>ParseTmChar
  Parses a letter (an upper case or lower case character). Returns the
parsed character.

Totality: total
Visibility: export
some : Monadm=>ParseTma->ParseTm (Lista)
  Succeeds if `p` succeeds, will continue to match `p` until it fails
and accumulate the results in a list

Visibility: export
many : Monadm=>ParseTma->ParseTm (Lista)
  Always succeeds, will accumulate the results of `p` in a list until it fails.

Visibility: export
hchainl : Monadm=>ParseTminit->ParseTm (init->arg->init) ->ParseTmarg->ParseTminit
  Parse left-nested lists of the form `((init op arg) op arg) op arg`

Visibility: export
hchainr : Monadm=>ParseTmarg->ParseTm (arg->end->end) ->ParseTmend->ParseTmend
  Parse right-nested lists of the form `arg op (arg op (arg op end))`

Visibility: export
takeWhile : Monadm=> (Char->Bool) ->ParseTmString
  Always succeeds, applies the predicate `f` on chars until it fails and creates a string
from the results.

Visibility: export
takeWhile1 : Monadm=> (Char->Bool) ->ParseTmString
  Similar to `takeWhile` but fails if the resulting string is empty.

Visibility: export
takeUntil : Monadm=>String->ParseTmString
  Takes from the input until the `stop` string is found.
Fails if the `stop` string cannot be found.

Visibility: export
spaces : Monadm=>ParseTm ()
  Parses zero or more space characters

Visibility: export
spaces1 : Monadm=>ParseTm ()
  Parses one or more space characters

Visibility: export
parens : Monadm=>ParseTma->ParseTma
  Discards brackets around a matching parser

Totality: total
Visibility: export
lexeme : Monadm=>ParseTma->ParseTma
  Discards whitespace after a matching parser

Visibility: export
token : Monadm=>String->ParseTm ()
  Matches a specific string, then skips following whitespace

Visibility: export
digit : Monadm=>ParseTm (Fin10)
  Matches a single digit

Totality: total
Visibility: export
natural : Monadm=>ParseTmNat
  Matches a natural number

Visibility: export
integer : Monadm=>ParseTmInteger
  Matches an integer, eg. "12", "-4"

Visibility: export
sepBy1 : Monadm=>ParseTma->ParseTmb->ParseTm (List1a)
  Parse repeated instances of at least one `p`, separated by `s`,
returning a list of successes.

@ p the parser for items
@ s the parser for separators

Visibility: export
sepBy : Monadm=>ParseTma->ParseTmb->ParseTm (Lista)
  Parse zero or more `p`s, separated by `s`s, returning a list of
successes.

@ p the parser for items
@ s the parser for separators

Visibility: export
commaSep1 : Monadm=>ParseTma->ParseTm (List1a)
  Parses /one/ or more occurrences of `p` separated by `comma`.

Visibility: export
commaSep : Monadm=>ParseTma->ParseTm (Lista)
  Parses /zero/ or more occurrences of `p` separated by `comma`.

Visibility: export
alternating : Monadm=>ParseTma->ParseTmb->ParseTm (Oddab)
  Parses alternating occurrences of `a`s and `b`s.
Can be thought of as parsing:
- a list of `b`s, separated, and surrounded, by `a`s
- a non-empty list of `a`s, separated by `b`s
where we care about the separators

Visibility: export
ntimes : Monadm=> (n : Nat) ->ParseTma->ParseTm (Vectna)
  Run the specified parser precisely `n` times, returning a vector
of successes.

Totality: total
Visibility: export