Proposal: instance Alternative ZipList

The ZipList data type admits one legal Alternative instance instance Alternative ZipList where pure = ZipList [] ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys) The legality of this instance was first noted in http://people.cs.kuleuven.be/~tom.schrijvers/Research/papers/ppdp2015.pdf I propose adding this instance, which acts like a generalized version of the Alternative for Maybe, choosing with a left bias. Discussion Period: 2 weeks -Edward

Er.. I obviously meant
instance Alternative ZipList where
empty = ZipList []
ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
sorry for any confusion.
On Fri, Jul 17, 2015 at 11:37 AM, Edward Kmett
The ZipList data type admits one legal Alternative instance
instance Alternative ZipList where pure = ZipList [] ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
The legality of this instance was first noted in http://people.cs.kuleuven.be/~tom.schrijvers/Research/papers/ppdp2015.pdf
I propose adding this instance, which acts like a generalized version of the Alternative for Maybe, choosing with a left bias.
Discussion Period: 2 weeks
-Edward

+1. It obeys laws. It feels zippy. LGTM.
On Friday, July 17, 2015, Edward Kmett
Er.. I obviously meant
instance Alternative ZipList where empty = ZipList [] ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
sorry for any confusion.
On Fri, Jul 17, 2015 at 11:37 AM, Edward Kmett
javascript:_e(%7B%7D,'cvml','ekmett@gmail.com');> wrote: The ZipList data type admits one legal Alternative instance
instance Alternative ZipList where pure = ZipList [] ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
The legality of this instance was first noted in http://people.cs.kuleuven.be/~tom.schrijvers/Research/papers/ppdp2015.pdf
I propose adding this instance, which acts like a generalized version of the Alternative for Maybe, choosing with a left bias.
Discussion Period: 2 weeks
-Edward
-- -- Dan Burton

The implementation could use some work. Something more like this, I think.
(<|>) = foldr (\x k ys -> x : k (drop 1 ys)) id
In pointless silliness, it's even
foldr ((. (. (maybe ([]) snd . uncons))) . (.) . (:)) id
On Jul 17, 2015 2:15 PM, "Edward Kmett"
Er.. I obviously meant
instance Alternative ZipList where empty = ZipList [] ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
sorry for any confusion.
On Fri, Jul 17, 2015 at 11:37 AM, Edward Kmett
wrote: The ZipList data type admits one legal Alternative instance
instance Alternative ZipList where pure = ZipList [] ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
The legality of this instance was first noted in http://people.cs.kuleuven.be/~tom.schrijvers/Research/papers/ppdp2015.pdf
I propose adding this instance, which acts like a generalized version of the Alternative for Maybe, choosing with a left bias.
Discussion Period: 2 weeks
-Edward
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

I'm more than open to switching to a more efficient solution.
-Edward
On Fri, Jul 17, 2015 at 5:16 PM, David Feuer
The implementation could use some work. Something more like this, I think.
(<|>) = foldr (\x k ys -> x : k (drop 1 ys)) id
In pointless silliness, it's even
foldr ((. (. (maybe ([]) snd . uncons))) . (.) . (:)) id On Jul 17, 2015 2:15 PM, "Edward Kmett"
wrote: Er.. I obviously meant
instance Alternative ZipList where empty = ZipList [] ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
sorry for any confusion.
On Fri, Jul 17, 2015 at 11:37 AM, Edward Kmett
wrote: The ZipList data type admits one legal Alternative instance
instance Alternative ZipList where pure = ZipList [] ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
The legality of this instance was first noted in http://people.cs.kuleuven.be/~tom.schrijvers/Research/papers/ppdp2015.pdf
I propose adding this instance, which acts like a generalized version of the Alternative for Maybe, choosing with a left bias.
Discussion Period: 2 weeks
-Edward
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

+1 from me, regardless of implementation.
On 4:18pm, Fri, Jul 17, 2015 Edward Kmett
I'm more than open to switching to a more efficient solution.
-Edward
On Fri, Jul 17, 2015 at 5:16 PM, David Feuer
wrote: The implementation could use some work. Something more like this, I think.
(<|>) = foldr (\x k ys -> x : k (drop 1 ys)) id
In pointless silliness, it's even
foldr ((. (. (maybe ([]) snd . uncons))) . (.) . (:)) id On Jul 17, 2015 2:15 PM, "Edward Kmett"
wrote: Er.. I obviously meant
instance Alternative ZipList where empty = ZipList [] ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
sorry for any confusion.
On Fri, Jul 17, 2015 at 11:37 AM, Edward Kmett
wrote: The ZipList data type admits one legal Alternative instance
instance Alternative ZipList where pure = ZipList [] ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
The legality of this instance was first noted in http://people.cs.kuleuven.be/~tom.schrijvers/Research/papers/ppdp2015.pdf
I propose adding this instance, which acts like a generalized version of the Alternative for Maybe, choosing with a left bias.
Discussion Period: 2 weeks
-Edward
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
participants (4)
-
Brent Yorgey
-
Dan Burton
-
David Feuer
-
Edward Kmett