<div dir="ltr">+1, I think I've defined one-off, specialized versions of this a dozen times.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 30, 2014 at 9:46 AM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>I found myself needing this type in my current overhaul of Data.Foldable, but it seems to be generally useful:<br></div><div><br>newtype Alt f a = Alt { getAlt :: f a } deriving <br>   (Eq,Ord,Show,Read,Typeable,Data,Generic,Num,Real,<br>     Floating, Fractional, RealFrac, RealFloat, Integral, Enum,<br>     Bounded,Ix,Functor,Foldable,Traversable,Applicative,<br>     Alternative,Monad,MonadPlus,MonadFix, IsString, IsList)<br></div><div>-- The laundry list of derived instances is as recommended by Edward Kmett, who would probably want more added if someone can think of more. Some of them would, of course, need to be derived in other modules. The key instance is this:<br></div><div><br></div>instance Alternative t => Monoid (Alt t a) where<br></div>  mempty = Alt empty<br></div>  (Alt m) `mappend` (Alt n) = Alt (m <|> n)<br></div></div></div></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>