<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Looks like the fmap definition for the Either functor matches what's given in Learn You A Haskell ...<br><br>instance Functor (Either a) where <br> fmap f (Right x) = Right (f x) <br> fmap f (Left x) = Left x<br><br>but Hoogle couldn't find Control.Monad.Instances<br><br>How else can I look at the code?<br><br>Michael<br><br>[michael@localhost ~]$ ghci<br>GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help<br>Loading package ghc-prim ... linking ... done.<br>Loading package integer-gmp ... linking ... done.<br>Loading package base ... linking ... done.<br>Loading package ffi-1.0 ... linking ... done.<br>Prelude> :m + Control.Monad.Instances<br>Prelude Control.Monad.Instances> :m + Data.Either<br>Prelude Control.Monad.Instances Data.Either> let l = Left 5<br>Prelude Control.Monad.Instances
Data.Either> fmap (*2) l<br>Left 5<br>Prelude Control.Monad.Instances Data.Either> let r = Right "five"<br>Prelude Control.Monad.Instances Data.Either> fmap length r<br>Right 4<br><br><br>--- On <b>Sat, 8/28/10, Brandon S Allbery KF8NH <i><allbery@ece.cmu.edu></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Brandon S Allbery KF8NH <allbery@ece.cmu.edu><br>Subject: Re: [Haskell-cafe] On to applicative<br>To: haskell-cafe@haskell.org<br>Date: Saturday, August 28, 2010, 9:06 PM<br><br><div class="plainMail">-----BEGIN PGP SIGNED MESSAGE-----<br>Hash: SHA1<br><br>On 8/28/10 20:43 , michael rice wrote:<br>> I'm looking at a discussion of Either (as functor) here:<br>> <br>> <a href="http://learnyouahaskell.com/making-our-own-types-and-typeclasses#the-functor-typeclass"
target="_blank">http://learnyouahaskell.com/making-our-own-types-and-typeclasses#the-functor-typeclass</a><br>> <br>> instance Functor (Either a) where <br>> fmap f (Right x) = Right (f x) <br>> fmap f (Left x) = Left x<br>> <br>> And this line in Data.Either<br>> <br>> Functor (Either a)<br>> <br>> but no fmap defined here.<br>> <br>> How come?<br><br>Historical accident, to wit: Haskell 98 minimally defined Either in the<br>Prelude, so in practice we get the basic definitions (Either itself and its<br>Functor and Monad instances) from the Prelude and other utility functions<br>from Data.Either.<br><br>- -- <br>brandon s. allbery [linux,solaris,freebsd,perl] <a ymailto="mailto:allbery@kf8nh.com" href="/mc/compose?to=allbery@kf8nh.com">allbery@kf8nh.com</a><br>system administrator [openafs,heimdal,too
many hats] <a ymailto="mailto:allbery@ece.cmu.edu" href="/mc/compose?to=allbery@ece.cmu.edu">allbery@ece.cmu.edu</a><br>electrical and computer engineering, carnegie mellon university KF8NH<br>-----BEGIN PGP SIGNATURE-----<br>Version: GnuPG v2.0.10 (Darwin)<br>Comment: Using GnuPG with Mozilla - <a href="http://enigmail.mozdev.org/" target="_blank">http://enigmail.mozdev.org/</a><br><br>iEYEARECAAYFAkx5sq4ACgkQIn7hlCsL25WA+QCeKUOuNN4kUpci9fH6BcFZ5WqG<br>bX8AoIBImpWLoxVz7kcwVIuHycYR/v5G<br>=EaIs<br>-----END PGP SIGNATURE-----<br>_______________________________________________<br>Haskell-Cafe mailing list<br><a ymailto="mailto:Haskell-Cafe@haskell.org" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></div></blockquote></td></tr></table><br>