class BinaryFunctor f where
bimap :: (a - c) - (b - d) - f a b - f c d
mapFst = (`bimap id`)
mapSnd = bimap id
On 31/05/2013 12:16 PM, Shachaf Ben-Kiki shac...@gmail.com wrote:
On Thu, May 30, 2013 at 7:12 PM, Shachaf Ben-Kiki shac...@gmail.com
wrote:
One generalization of them is to
On Thu, May 30, 2013 at 10:56 PM, Tony Morris tmor...@tmorris.net wrote:
class BinaryFunctor f where
bimap :: (a - c) - (b - d) - f a b - f c d
mapFst = (`bimap id`)
mapSnd = bimap id
There's a bifunctors package with:
class Bifunctor f where
bimap :: ...
first :: a - b - f a c
On Tue, May 28, 2013 at 1:54 AM, Dominique Devriese
dominique.devri...@cs.kuleuven.be wrote:
Hi all,
I often find myself needing the following definitions:
mapPair :: (a - b) - (c - d) - (a,c) - (b,d)
mapPair f g (x,y) = (f x, g y)
mapFst :: (a - b) - (a,c) - (b,c)
mapFst f =
On Thu, May 30, 2013 at 7:12 PM, Shachaf Ben-Kiki shac...@gmail.com wrote:
One generalization of them is to lenses. For example `lens` has
both, _1, _2, such that mapPair = over both, mapFst = over
_1, etc., but you can also get fst = view _1, set _2 = \y' (x,_)
- (x,y'), and so on. (Since
On Tue, May 28, 2013 at 7:46 PM, Dominique Devriese
dominique.devri...@cs.kuleuven.be wrote:
2013/5/28 Tikhon Jelvis tik...@jelv.is:
These are present in Control.Arrow as (***), first and second
respectively.
Right, thanks. Strange that neither Hayoo nor Hoogle turned these up..
HLint
Hi all,
I often find myself needing the following definitions:
mapPair :: (a - b) - (c - d) - (a,c) - (b,d)
mapPair f g (x,y) = (f x, g y)
mapFst :: (a - b) - (a,c) - (b,c)
mapFst f = mapPair f id
mapSnd :: (b - c) - (a,b) - (a,c)
mapSnd = mapPair id
But they seem missing from the
You might want to look at the arrow type class and the instance for (-).
Ben
On 28 May 2013 09:56, Dominique Devriese
dominique.devri...@cs.kuleuven.be wrote:
Hi all,
I often find myself needing the following definitions:
mapPair :: (a - b) - (c - d) - (a,c) - (b,d)
mapPair f g (x,y)
These are present in Control.Arrow as (***), first and second respectively.
They are easy to overlook because they work for *all* arrows, not just
functions. So the type signatures look like:
first :: Arrow a = a b c - a (b, d) (c, d)
If you replace a with (-), you'll see that this is
On Tue, May 28, 2013 at 10:54 AM, Dominique Devriese
dominique.devri...@cs.kuleuven.be wrote:
Hi all,
I often find myself needing the following definitions:
mapPair :: (a - b) - (c - d) - (a,c) - (b,d)
mapPair f g (x,y) = (f x, g y)
That's Control.Arrow.(***), e.g.:
ghci (+3)
I have them defined for my stuff.
Generally I find it much quicker to roll my own than to
(1) ask on this list if someone else has done it...
(2) look at arrows or
MyFavouriteCategoryTheoryBitOfFPBecauseICantGetAbstractEnough
and the try to figure out what is going on.
The joy of Haskell
2013/5/28 Tikhon Jelvis tik...@jelv.is:
These are present in Control.Arrow as (***), first and second respectively.
Right, thanks. Strange that neither Hayoo nor Hoogle turned these up..
Dominique
___
Haskell-Cafe mailing list
Dne 28.5.2013 10:54, Dominique Devriese napsal(a):
Hi all,
I often find myself needing the following definitions:
mapPair :: (a - b) - (c - d) - (a,c) - (b,d)
mapPair f g (x,y) = (f x, g y)
mapFst :: (a - b) - (a,c) - (b,c)
mapFst f = mapPair f id
mapSnd :: (b - c) - (a,b) -
See Agda.Utils.Tuple :-)
-- | Bifunctoriality for pairs.
(-*-) :: (a - c) - (b - d) - (a,b) - (c,d)
(f -*- g) ~(x,y) = (f x, g y)
-- | @mapFst f = f -*- id@
mapFst :: (a - c) - (a,b) - (c,b)
mapFst f ~(x,y) = (f x, y)
-- | @mapSnd g = id -*- g@
mapSnd :: (b - d) - (a,b) - (a,d)
mapSnd g ~(x,y)
`mapPair` also exists as `tup2` in patch-combinators:
http://hackage.haskell.org/package/patch-combinators
/ Emil
2013-05-28 16:01, Andreas Abel skrev:
See Agda.Utils.Tuple :-)
-- | Bifunctoriality for pairs.
(-*-) :: (a - c) - (b - d) - (a,b) - (c,d)
(f -*- g) ~(x,y) = (f x, g y)
-- |
14 matches
Mail list logo