advent-0.1.0.0: Advent of Code common library
Copyright(c) Eric Mertens 2021
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Advent.ReadS

Contents

Description

Make it easier to use ReadS.

Synopsis

Documentation

newtype P a Source #

Wrapper for ReadS

Constructors

P 

Fields

Instances

Instances details
MonadFail P Source # 
Instance details

Defined in Advent.ReadS

Methods

fail :: String -> P a #

Alternative P Source # 
Instance details

Defined in Advent.ReadS

Methods

empty :: P a #

(<|>) :: P a -> P a -> P a #

some :: P a -> P [a] #

many :: P a -> P [a] #

Applicative P Source # 
Instance details

Defined in Advent.ReadS

Methods

pure :: a -> P a #

(<*>) :: P (a -> b) -> P a -> P b #

liftA2 :: (a -> b -> c) -> P a -> P b -> P c #

(*>) :: P a -> P b -> P b #

(<*) :: P a -> P b -> P a #

Functor P Source # 
Instance details

Defined in Advent.ReadS

Methods

fmap :: (a -> b) -> P a -> P b #

(<$) :: a -> P b -> P a #

Monad P Source # 
Instance details

Defined in Advent.ReadS

Methods

(>>=) :: P a -> (a -> P b) -> P b #

(>>) :: P a -> P b -> P b #

return :: a -> P a #

a ~ String => IsString (P a) Source #

String literals match with tok

Instance details

Defined in Advent.ReadS

Methods

fromString :: String -> P a #

runP :: P a -> String -> a Source #

Parse a string or throw an error

tok :: String -> P String Source #

Match a specific string token and return it.

char :: Char -> P () Source #

Match a leading character

Combinators

sepBy1 Source #

Arguments

:: P a

element

-> P b

separator

-> P [a] 

Parse a separated, nonempty list.

sepBy Source #

Arguments

:: P a

element

-> P b

separator

-> P [a] 

Parse a separated list.

between Source #

Arguments

:: P a

open

-> P b

close

-> P c

body

-> P c 

Convenience function for surrounding a parser with other other parsers.

eof :: P () Source #

Parser that succeeds at end of input string.

pread :: Read a => P a Source #

Parse using a Read instance.

preadParen :: Bool -> P a -> P a Source #

Wrapper for readParen

(<++) :: P a -> P a -> P a infixr 3 Source #

Left-biased choice. Uses righthand-side if lefthand-side fails.