Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hangs #1

Closed
FranklinChen opened this issue Feb 21, 2015 · 4 comments
Closed

Hangs #1

FranklinChen opened this issue Feb 21, 2015 · 4 comments

Comments

@FranklinChen
Copy link

The following result hangs:

{-# LANGUAGE OverloadedStrings #-}

import Language.Lexer.Applicative (tokens)
import Text.Regex.Applicative
import qualified Data.Loc as Loc
import qualified Data.Char as Char

type Token = Integer

token :: RE Char Token
token = "one" *> pure 1

spaces :: RE Char ()
spaces = (many $ psym Char.isSpace) *> pure ()

result :: [Loc.L Token]
result = tokens token spaces "filename" "one -"
@UnkindPartition
Copy link
Owner

This is because you allow empty whitespace. Use some instead of many.

@UnkindPartition
Copy link
Owner

On a second thought, we can do better than that. I've just released 1.0.0.1 which correctly reports the lexical error in your example.

@FranklinChen
Copy link
Author

Ah, oops, I didn't read the API carefully... I'm used to words like many meaning "0 or more" and many1 meaning "1 or more", as in Parsec.

@UnkindPartition
Copy link
Owner

Right. regex-applicative reuses combinators from Control.Applicative where applicable, and they sometimes differ from the Parsec names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants