[Haskell-cafe] List instance of Alternative: why (++)?
Theodore Lief Gannon
tanuki at gmail.com
Sat May 6 06:12:04 UTC 2017
Fiddling around, I found myself wanting:
coalesce :: [a] -> [a] -> [a]
-- or -- :: (Foldable t) => t a -> t a -> t a
coalesce a b = if null a then b else a
I expected this to be (<|>) (it is for Maybe!) but instead I find no
canonical implementation of it anywhere, and what seems like a useless instance
Alternative []. What's the rationale?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170505/e12893e2/attachment.html>
More information about the Haskell-Cafe
mailing list