[GHC] #9759: Add Alternative wrapper to Data.Monoid

GHC ghc-devs at haskell.org
Mon Nov 3 14:25:26 UTC 2014


#9759: Add Alternative wrapper to Data.Monoid
-------------------------------------+-------------------------------------
       Reporter:  dfeuer             |                   Owner:  dfeuer
           Type:  task               |                  Status:  new
       Priority:  normal             |               Milestone:  7.10.1
      Component:  Core Libraries     |                 Version:  7.9
       Keywords:                     |        Operating System:
   Architecture:  Unknown/Multiple   |  Unknown/Multiple
     Difficulty:  Easy (less than 1  |         Type of failure:
  hour)                              |  None/Unknown
     Blocked By:                     |               Test Case:
Related Tickets:                     |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
 As discussed on the libraries list,

 {{{#!hs
 -- | Monoid under @<|>@.
 newtype Alt f a = Alt {getAlt :: f a}
   deriving (Generic, Generic1, Read, Show, Eq, Ord, Num, Enum,
             Monad, MonadPlus, Applicative, Alternative, Functor)

 instance forall f a . Alternative f => Monoid (Alt f a) where
   mempty = Alt empty
   mappend = coerce ((<|>) :: f a -> f a -> f a)
 }}}

 The documentation for `Data.Monoid.First` and `Data.Monoid.Last` should
 also be expanded to explain that `First a` is isomorphic to `Alt Maybe a`
 and `Last a` is isomorphic to `Dual (Alt Maybe a)`.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9759>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list