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
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
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
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):
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
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
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
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
(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
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
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
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
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
13 matches
Mail list logo