
#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: | -------------------------------------+------------------------------------- Changes (by Iceland_jack): * type: bug => feature request 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:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler