[GHC] #13520: instance Alternative ZipList

GHC ghc-devs at haskell.org
Mon Apr 3 18:06:35 UTC 2017


#13520: instance Alternative ZipList
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  libraries/base    |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by Iceland_jack:

Old description:

> The paper "From monoids to near-semirings:
> the essence of `MonadPlus` and `Alternative`" mentions
>
> > Perhaps surprisingly, `ZipList`s have an `Alternative` instance.
> Like the `Alternative` instance for `Maybe`, the one for `ZipList` has
> a left bias.
> >
> > {{{#!hs
> > instance Alternative ZipList where
> >   empty :: ZipList a
> >   empty           = ZL []
> >
> >   (<|>) :: ZipList a -> ZipList a -> ZipList a
> >   ZL xs <|> ZL ys = ZL (xs ++ drop (length xs) ys)
> > }}}
>
> Has this been considered for base?

New description:

 The paper "From monoids to near-semirings:
 the essence of `MonadPlus` and `Alternative`" mentions

 > Perhaps surprisingly, `ZipList`s have an `Alternative` instance.
 > Like the `Alternative` instance for `Maybe`, the one for `ZipList` has
 a left bias.
 >
 > {{{#!hs
 > instance Alternative ZipList where
 >   empty :: ZipList a
 >   empty           = ZL []
 >
 >   (<|>) :: ZipList a -> ZipList a -> ZipList a
 >   ZL xs <|> ZL ys = ZL (xs ++ drop (length xs) ys)
 > }}}

 Has this been considered for base?

--

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


More information about the ghc-tickets mailing list