[Haskell-cafe] for = flip map
sjoerd at w3future.com
Thu Mar 29 23:03:59 CEST 2012
Some more bikeshedding:
Perhaps ffor, as in
ffor = flip fmap
infixr 0 <$$>
(<$$>) = flip (<$>)
xs <$$> \x -> ...
In both cases they should go in Data.Functor
On Mar 28, 2012, at 11:26 PM, ezra at ezrakilty.net wrote:
> I would very much like to see a standard function for "flip map" along
> these lines. I think it would make a lot of code more readable.
> Like the OP, I use "for" in my own code. It's unfortunate that
> Data.Traversable takes the name with another type. Two options would be
> to (a) reuse the name in Data.List and force people to qualify as
> necessary, or (b) choose another name for "flip map".
> Regarding other possible names: forall is a keyword and forAll is used
> by QuickCheck. One possibility would be "foreach".
> On Wed, Mar 28, 2012, at 10:19 PM, Christopher Done wrote:
>> On 28 March 2012 22:05, Matthew Steele <mdsteele at alum.mit.edu> wrote:
>>> Doesn't for already exist, in Data.Traversable? Except that for =
>>> flip traverse.
>> Traverse doesn't fit the type of fmap, it demands an extra type
>> traverse :: (Traversable t,Applicative f) => (a -> f b) -> t a -> f (t b)
>> fmap :: Functor f => (a -> b) -> f a -> f b
>> Note the (a -> f b) instead of (a -> b).
>> fmap :: (a -> b) -> [a] -> [b]
>> can't be expressed with traverse, you can only get this far:
>> traverse :: (a -> [b]) -> [a] -> [[b]]
>> Unless I'm missing something.
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe