Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-19 Thread Edward Kmett
On Fri, Jul 17, 2009 at 10:37 PM, por...@porg.es wrote: 2009/7/18 Edward Kmett ekm...@gmail.com: I wrote a short blog post on this: http://comonad.com/reader/2008/zipping-and-unzipping-functors/ and one on the less powerful dual operations (less powerful because while every Haskell Functor

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-17 Thread Jules Bean
Job Vranish wrote: I was needing a way to zip generic data structures together today and was very annoyed to find that there is no Zippable class, or variant there of. Notice that you can always do this if the LHS is traversable and the RHS is Foldable (as a special case the RHS is the

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-17 Thread Edward Kmett
There is a Zip class in category-extras 's Control.Functor.Zip on hackage that covers this use-case. http://hackage.haskell.org/packages/archive/category-extras/latest/doc/html/Control-Functor-Zip.html It can basically be viewed as the ap of an Applicative functor chosen to be the left inverse

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-17 Thread porges
2009/7/18 Edward Kmett ekm...@gmail.com: I wrote a short blog post on this: http://comonad.com/reader/2008/zipping-and-unzipping-functors/ and one on the less powerful dual operations (less powerful because while every Haskell Functor is strong, much fewer are costrong):

[Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-16 Thread Job Vranish
I was needing a way to zip generic data structures together today and was very annoyed to find that there is no Zippable class, or variant there of. So I made my own: class (Foldable f, Functor f) = Zippable f where fmaps :: (Foldable g) = g (a - b) - f a - f b fmaps' :: [a - b] - f a - f b

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-16 Thread Jake McArthur
I think there are some basic equivalents in the TypeCompose and category-extras packages, for the record, but a standalone version wouldn't hurt either! - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-16 Thread Jeff Heard
Beautiful. Can we have a version on hackage? On Thu, Jul 16, 2009 at 5:56 PM, Job Vranishjvran...@gmail.com wrote: I was needing a way to zip generic data structures together today and was very annoyed to find that there is no Zippable class, or variant there of. So I made my own: class

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-16 Thread Dan Weston
After rereading page 2 of McBride and Paterson's Functional Pearl, Applicative programming with effects, I think you are just reinventing Control.Applicative. The problem is that the default Applicative instance for [] is wrong, being a direct product rather than a direct sum. If [] were not

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-16 Thread Ryan Ingram
(I'm going to play fast and loose with constructors for this post, treating MyList and ZipList as if they were []) On Thu, Jul 16, 2009 at 4:10 PM, Dan Westonweston...@imageworks.com wrote: -- different from [], sum rather than product instance Applicative MyList where  pure x = x ::: Nil  

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-16 Thread Dan Weston
Way cool. I have gained newfound respect for what I don't know. :) Can there ever be more than one (observably different) valid definition of pure for a given * that obeys all the laws? I would imagine that there could be at most one. Dan Ryan Ingram wrote: (I'm going to play fast and

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-16 Thread Job Vranish
Yeah I tried applicative, but saw that the * operator didn't do what I want with lists, and started looking elsewhere. I didn't even see the ZipList! Actually the other problem is that the data structure that I'm using won't support pure, so no Applicative :( Though for a generic zip, Applicative

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-16 Thread Janis Voigtlaender
Why is there no Zippable class? There is. You can use Data.Zippable from http://hackage.haskell.org/package/bff. It gives you a function tryZip :: Zippable k = k a - k b - Either String (k (a,b)) The Either in the return type is to capture an error message in case the two structures are not

Re: [Haskell-cafe] Why is there no Zippable class? Would this work?

2009-07-16 Thread Johan Jeuring
Why is there no Zippable class? There is. You can use Data.Zippable from http://hackage.haskell.org/package/bff. It gives you a function tryZip :: Zippable k = k a - k b - Either String (k (a,b)) The Either in the return type is to capture an error message in case the two structures are