I would like to use the some function from Alternative http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Base.html#some.
I've tried:
*MyParser Data.Attoparsec.Text Control.Applicative Data.Text> some [3443]
ewrewrew
ewrwwwwww545
43535
435
^CInterrupted.
As you can see, I interrupted the input. How can I use the some function?
Consider what happens when you try to expand
some [1]:Here's I've immediately replaced
<|>with(++). Because(++)is strict in its first argument, you have to evaluatesome_vbefore proceeding, but that gets us into an infinite loop.Alternativeis described as a monoid for applicative functors. If I understand correctly,some xswould be the infinite list of non-empty lists you could create by taking one element fromxsat a time.and
many xswould be the infinite list of (possibly empty) lists (essentially, just[]:some xs.) Because of the strictness of(++), though, the result is not computed lazily, so you never actually terminate.