Conversation
|
I'm yet to fix the folds in the parser modules. |
67adb63 to
95ea228
Compare
774fedc to
4dbb832
Compare
e8f7efd to
c6ec02d
Compare
f79f964 to
3bdcb85
Compare
645d96a to
27c7820
Compare
|
close and reopen. |
harendra-kumar
left a comment
There was a problem hiding this comment.
- Do not store the
Stepconstructor in the fold state. - Write the applicative
<*>asteeWithfunction and define the applicative in terms of that. See the parser teeWith functions. Do not storeStepin the state.
| @@ -311,21 +319,21 @@ either parser = Parser step initial extract | |||
| take :: Monad m => Int -> Fold m a b -> Parser m a b | |||
| take n (Fold fstep finitial fextract) = Parser step initial extract | |||
There was a problem hiding this comment.
This is same as the take in Fold. This is just fromFold (FL.take n fld).
Instead, this can be converted into: take :: Int -> Parser m a b -> Parser m a b.
There was a problem hiding this comment.
It will be inconsistent with other takeist combinators.
There was a problem hiding this comment.
takeP :: Int -> Parser m a b -> Parser m a b
| @@ -404,16 +412,16 @@ takeGE cnt (Fold fstep finitial fextract) = Parser step initial extract | |||
| {-# INLINE takeWhile #-} | |||
| takeWhile :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b | |||
| takeWhile predicate (Fold fstep finitial fextract) = | |||
There was a problem hiding this comment.
This is the same as the takeWhile in Folds i.e. fromFold . takeWhile p. This one should now be replaced by the takeWhileP of PR #597 .
|
Remember to update the changelog for the behavior change of folds. |
harendra-kumar
left a comment
There was a problem hiding this comment.
I did not review the split using sequence functions yet. Will review those in the next iteration. Still need to check performance results.
| sum = Fold (\x a -> return $ x + a) (return 0) return | ||
| sum = Fold (\x a -> return $ Partial $ x + a) (return 0) return | ||
|
|
||
| -- XXX Have a terminating condition here if `a == 0` |
There was a problem hiding this comment.
Remove this comment.
A potential down side is that it cannot be used where only accumulators can be used.
| return $ Partial n (ManyTillR 0 fs1 l) | ||
| FL.Done fb -> return $ Done n fb | ||
| -- Keep a count of elements | ||
| FL.Done1 _ -> error "Done1 nore supported in manyTill" |
There was a problem hiding this comment.
Since we are maintaining a count we can return Done cnt fb in this case? Otherwise why are we even maintaining that count, its not being used anywhere.
There was a problem hiding this comment.
You can check the previous commit, I initially did that, but for some reason when I looked at it again, I somehow got the idea that it was wrong. Now that I look at it again, it looks fine to me.
* The only difference from the previous implementation is that the `if` statement encompasses `collect` rather then the other way around.
|
Look at #770 |
Closes #455