Functor (Either a)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Functor (Either a)

Conor McBride
Hi all

I read TFM

   http://haskell.org/ghc/docs/latest/html/libraries/base/ 
Prelude.html#t%3AFunctor

and it does rather suggest that there's an instance of Functor for  
(Either a). Yet,

    ___         ___ _
   / _ \ /\  /\/ __(_)
  / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell  
98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
Prelude> fmap not (Right True)

<interactive>:1:0:
     No instance for (Functor (Either a))
       arising from use of `fmap' at <interactive>:1:0-20


Am I being dim?

Conor

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Functor (Either a)

Ian Lynagh

Hi Conor,

On Sun, Jul 15, 2007 at 08:20:25PM +0100, Conor McBride wrote:
>
> and it does rather suggest that there's an instance of Functor for  
> (Either a). Yet,
>
> Prelude> fmap not (Right True)
>
> <interactive>:1:0:
>     No instance for (Functor (Either a))
>       arising from use of `fmap' at <interactive>:1:0-20

It's in Control.Monad.Instances:

Prelude> :m + Control.Monad.Instances
Prelude Control.Monad.Instances> fmap not (Right True)
Right False

I don't know if there's a way of deducing that from the haddock
documentation.


Thanks
Ian

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Functor (Either a)

Bryan O'Sullivan
Ian Lynagh wrote:

> It's in Control.Monad.Instances:
>
> Prelude> :m + Control.Monad.Instances
> Prelude Control.Monad.Instances> fmap not (Right True)
> Right False
>
> I don't know if there's a way of deducing that from the haddock
> documentation.

There doesn't seem to be.  I didn't discover that module until I finally
sat down and spent 15 minutes trying to answer the question "why is
importing, or omitting, some completely unrelated mtl module influencing
my program's ability to compile?"

Wonderful as haddock is, there's no substitute for having the GHC
sources and half of hackage unpacked on your hard disk, to make possible
a few rounds of "grep -r".

        <b
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re[2]: Functor (Either a)

Bulat Ziganshin-2
Hello Bryan,

Monday, July 16, 2007, 2:16:17 AM, you wrote:

> There doesn't seem to be.  I didn't discover that module until I finally
> sat down and spent 15 minutes trying to answer the question "why is
> importing, or omitting, some completely unrelated mtl module influencing
> my program's ability to compile?"

instances are standard answer. they are as viruses, imperceptibly
filtering through any import lists :)

--
Best regards,
 Bulat                            mailto:[hidden email]

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries