1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE Safe #-}
-- |
-- Module : Text.Megaparsec.Common
-- Copyright : © 2018–present Megaparsec contributors
-- License : FreeBSD
--
-- Maintainer : Mark Karpov <markkarpov92@gmail.com>
-- Stability : experimental
-- Portability : portable
--
-- Common token combinators. This module is not public, the functions from
-- it are re-exported in "Text.Megaparsec.Byte" and "Text.Megaparsec.Char".
--
-- @since 7.0.0
module Text.Megaparsec.Common
( string,
string',
)
where
import qualified Data.CaseInsensitive as CI
import Data.Function (on)
import Text.Megaparsec
-- | A synonym for 'chunk'.
string :: (MonadParsec e s m) => Tokens s -> m (Tokens s)
string = chunk
{-# INLINE string #-}
-- | The same as 'string', but case-insensitive. On success returns string
-- cased as the parsed input.
--
-- >>> parseTest (string' "foobar") "foObAr"
-- "foObAr"
string' ::
(MonadParsec e s m, CI.FoldCase (Tokens s)) =>
Tokens s ->
m (Tokens s)
string' = tokens ((==) `on` CI.mk)
{-# INLINE string' #-}
|