since import { not } from 'fp-ts/lib/function' ; import { monoidString } from 'fp-ts/lib/Monoid' ; import { pipe } from 'fp-ts/lib/pipeable' ; import * as P from './Parser' ; const maybe = P . maybe ( monoidString ) ; category since export type Char = string ; category since export const char = c => P . expected ( P . sat ( s => s === c ) , `"${ c }"` ) ; category since export const notChar = c => P . expected ( P . sat ( c1 => c1 !== c ) , `anything but "${ c }"` ) ; const isOneOf = ( s , c ) => s . indexOf ( c ) !== - 1 ; category since export const oneOf = s => P . expected ( P . sat ( c => isOneOf ( s , c ) ) , `One of "${ s }"` ) ; category since export const notOneOf = s => P . expected ( P . sat ( c => ! isOneOf ( s , c ) ) , `Not one of ${ JSON . stringify ( s ) }` ) ; category since export const many = parser => maybe ( many1 ( parser ) ) ; category since export const many1 = parser => pipe ( P . many1 ( parser ) , P . map ( nea => nea . join ( '' ) ) ) ; const isDigit = c => '0123456789' . indexOf ( c ) !== - 1 ; category since export const digit = P . expected ( P . sat ( isDigit ) , 'a digit' ) ; const spaceRe = /^\s$/ ; const isSpace = c => spaceRe . test ( c ) ; category since export const space = P . expected ( P . sat ( isSpace ) , 'a whitespace' ) ; const isUnderscore = c => c === '_' ; const isLetter = c => /[a-z]/ . test ( c . toLowerCase ( ) ) ; const isAlphanum = c => isLetter ( c ) || isDigit ( c ) || isUnderscore ( c ) ; category since export const alphanum = P . expected ( P . sat ( isAlphanum ) , 'a word character' ) ; since export const letter = P . expected ( P . sat ( isLetter ) , 'a letter' ) ; const isUnicodeLetter = c => c . toLowerCase ( ) !== c . toUpperCase ( ) ; category since export const unicodeLetter = P . expected ( P . sat ( isUnicodeLetter ) , 'an unicode letter' ) ; const isUpper = c => isLetter ( c ) && c === c . toUpperCase ( ) ; category since export const upper = P . expected ( P . sat ( isUpper ) , 'an upper case letter' ) ; const isLower = c => isLetter ( c ) && c === c . toLowerCase ( ) ; category since export const lower = P . expected ( P . sat ( isLower ) , 'a lower case letter' ) ; category since export const notDigit = P . expected ( P . sat ( not ( isDigit ) ) , 'a non-digit' ) ; category since export const notSpace = P . expected ( P . sat ( not ( isSpace ) ) , 'a non-whitespace character' ) ; category since export const notAlphanum = P . expected ( P . sat ( not ( isAlphanum ) ) , 'a non-word character' ) ; category since export const notLetter = P . expected ( P . sat ( not ( isLetter ) ) , 'a non-letter character' ) ; category since export const notUpper = P . expected ( P . sat ( not ( isUpper ) ) , 'anything but an upper case letter' ) ; category since export const notLower = P . expected ( P . sat ( not ( isLower ) ) , 'anything but a lower case letter' ) ;