HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

ModuleAgda-2.8.0.2Haskell2010

Agda.Syntax.Parser.LookAhead

When lexing by hand (for instance string literals) we need to do some looking ahead. The LookAhead monad keeps track of the position we are currently looking at, and provides facilities to synchronise the look-ahead position with the actual position of the Parser monad (see sync and rollback).

Contents
  1. The LookAhead monad
  2. Operations
Synopsis
  • PackageAgda-2.8.0.2
  • Exports12
  • LanguageHaskell2010
  • LicenceMIT
  • SourceLookAhead.hs

The LookAhead monad

newtypenewtype LookAhead a

The LookAhead monad is basically a state monad keeping with an extra AlexInput, wrapped around the Parser monad.

Instances3Monad, Functor, Applicative

Operations

valuesync :: LookAhead ()

Consume all the characters up to the current look-ahead position.

valuematch :: [(String, LookAhead a)] -> LookAhead a -> LookAhead a

Do a case on the current input string. If any of the given strings match we move past it and execute the corresponding action. If no string matches, we execute a default action, advancing the input one character. This function only affects the look-ahead position.