Looks like the fmap definition for the Either functor matches what's given in Learn You A Haskell ... instance Functor (Either a) where fmap f (Right x) = Right (f x) fmap f (Left x) = Left x but Hoogle couldn't find Control.Monad.Instances How else can I look at the code? Michael [michael@localhost ~]$ ghci GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package ffi-1.0 ... linking ... done. Prelude> :m + Control.Monad.Instances Prelude Control.Monad.Instances> :m + Data.Either Prelude Control.Monad.Instances Data.Either> let l = Left 5 Prelude Control.Monad.Instances Data.Either> fmap (*2) l Left 5 Prelude Control.Monad.Instances Data.Either> let r = Right "five" Prelude Control.Monad.Instances Data.Either> fmap length r Right 4 --- On Sat, 8/28/10, Brandon S Allbery KF8NH <allbery@ece.cmu.edu> wrote:
|