
I believed second == fmap (on pairs) also until very recently. See
http://netsuperbrain.com/blog/posts/analysis-of-lazy-stream-programs/
http://lukepalmer.wordpress.com/2008/10/03/laziness-and-the-monad-laws/
Hm!
- Conal
On Tue, Nov 18, 2008 at 10:41 AM, Robin Green
fmap actually does the same thing as second (when applied to pairs), so you can replace second with fmap.
If you want to go insane, you can actually make this redefinition:
import Prelude hiding ((.))
infixr 9 . (.) :: (Functor f) => (a -> b) -> f a -> f b (.) = fmap
and then just use (.) (either infix or bracketed) instead of fmap throughout.
-- Robin
On Tue, 18 Nov 2008 10:23:37 -0800 "Conal Elliott"
wrote: You can also mix in 'first' and 'second' arbitrarily and read them directly from the type as well, when there is (possibly nested) pair structure on the way to the value being modified. That's why I call fmap, first, and second "semantic editor combinators". Sometime soon I'm going to blog about these tricks.
- Conal
On Tue, Nov 18, 2008 at 10:20 AM, Creighton Hogg
wrote: On Tue, Nov 18, 2008 at 12:15 PM, Conal Elliott
wrote: Also, a less forgetful version of subs might be useful:
withSubs xs e :: [a] -> Event b -> Event (b,a)
and then
subs xs e = snd <$> withSubs xs e
or, if you like,
subs = (fmap.fmap.fmap) snd withSubs
Btw, you can read the three fmaps directly from the signature of withSubs (two arrows plus one Event on the way to the pair).
- Conal
That's a cute trick with the number of fmap's required. Never thought of it that way.
Also, I'd like to apologize for not mentioning quicksilver from #haskell in my last e-mail. An honest slip-up, but an inappropriate one.
Reactive mailing list Reactive@haskell.org http://www.haskell.org/mailman/listinfo/reactive