razom-text-util-0.1.1.0: src/Text/Razom/Types.hs
{- This file is part of razom-text-util.
-
- Written in 2015 by fr33domlover <fr33domlover@rel4tion.org>.
-
- ♡ Copying is an act of love. Please copy, reuse and share.
-
- The author(s) have dedicated all copyright and related and neighboring
- rights to this software to the public domain worldwide. This software is
- distributed without any warranty.
-
- You should have received a copy of the CC0 Public Domain Dedication along
- with this software. If not, see
- <http://creativecommons.org/publicdomain/zero/1.0/>.
-}
module Text.Razom.Types
( Regex
, PosRegex
, LexError (..)
, LexResult (..)
)
where
import Data.Position (Position, PosRE)
import Text.Regex.Applicative (RE)
-- | A regular expression over Unicode characters.
type Regex a = RE Char a
-- | A position-aware regular expression over Unicode characters.
type PosRegex a = PosRE Char a
-- | An error returned when applying a regex fails. Parameters:
--
-- (1) Location of the error
-- (2) Previous tokens parsed successfully
-- (3) The rest of the text
data LexError t = LexError Position [t] String deriving Show
-- | What is returned by lexical analyzer.
type LexResult t = Either (LexError t) [t]