Add a pattern match for the single-element list to stop it from hitting the empty list base case.
On Fri, Jun 10, 2016 at 05:37:41PM +0300, Юрий Сыровецкий (Yuriy Syrovetskiy) wrote:
> It is so because in base library
>
> asum = foldr (<|>) empty
>
> What if it was defined
>
> asum [] = empty
> asum [x:xs] = x <|> asum xs
Those are the same (assuming you mean (x:xs) instead of [x:xs]).
Tom
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe