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

Add till' #115

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add till' #115

wants to merge 6 commits into from

Conversation

Shou
Copy link

@Shou Shou commented Mar 30, 2016

#93

@bgamari
Copy link
Collaborator

bgamari commented Apr 8, 2016

It would be nice if the commit history were a bit cleaner. Why not just fold the last three commits together?

-- This complements @manyTill@ and can be used to find a specific
-- pattern in a text.
--
-- The value returned by @p@ is forced to WHNF.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is true, is it?

@Shou
Copy link
Author

Shou commented Apr 23, 2016

@bgamari you're right, and skipTill' p wasn't forced to WHNF either. I've removed the comment regarding forcing WHNF in skipTill, and should've fixed skipTill' in this commit.

skipTill' :: (MonadPlus m) => m a -> m b -> m b
skipTill' p end = scan
where scan = end `mplus` (p !*> scan)
(!*>) !a0 a1 = a0 *> a1
Copy link
Collaborator

@bgamari bgamari Jun 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will force the m a but presumably you wanted to instead force the a, right?

@@ -267,7 +267,7 @@ skipTill p end = scan
skipTill' :: (MonadPlus m) => m a -> m b -> m b
skipTill' p end = scan
where scan = end `mplus` (p !*> scan)
(!*>) !a0 a1 = a0 *> a1
(!*>) a0 a1 = fmap (\(!a) -> a) a0 *> a1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bgamari This should do it, right?

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

Successfully merging this pull request may close these issues.

3 participants