
19 Sep
2015
19 Sep
'15
1:13 p.m.
On Sat, Sep 19, 2015 at 01:25:00AM -0400, David Feuer wrote:
It kind of seems like there should be fold-like things to match some and many.
foldrAlt :: Alternative f => (a -> b -> b) -> b -> f a -> f b foldrAlt c n m = foldr1Alt c n m <|> pure n
foldr1Alt :: Alternative f => (a -> b -> b) -> b -> f a -> f b foldr1Alt c n m = c <$> m <*> foldrAlt c n m [...]
An Alternative allows list-like behaviour when it comes to *construction*, but offers no operation analogous to pattern-matching and therefore doesn't allow you to look inside it or do any sort of *destruction*. I tried foldrAlt and it looped forever, as I expected. I also expect the others to loop forever. Tom