Some more bikeshedding:

Perhaps ffor, as in

    ffor = flip fmap

or perhaps

    infixr 0 <$$>
    (<$$>) = flip (<$>)

    xs <$$> \x -> ...

(cf. <**>)

In both cases they should go in Data.Functor

Sjoerd

On Mar 28, 2012, at 11:26 PM, [email protected] 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".
> 
> Ezra
> 
> On Wed, Mar 28, 2012, at 10:19 PM, Christopher Done wrote:
>> On 28 March 2012 22:05, Matthew Steele <[email protected]> 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
>> constructor:
>> 
>> 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).
>> 
>> E.g.
>> 
>> 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
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 

--
Sjoerd Visscher
https://github.com/sjoerdvisscher/blog






_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to