
On 21 March 2005 10:24, Thomas Hallgren wrote:
Superclasses are never really needed, are they? But they are useful because they make types smaller and more readable.
Well, superclasses might be required by default methods.
For a given type T which has a Monad instance, you can always declare
instance Functor T where fmap = liftM
so it is not a big burden to have to declare a Functor instance to accompany a Monad instance.
I don't really have a strong view about this, I'm happy to defer to those who know more about it. But I have a slight preference for not having to define Functor instance if I don't need one - lots of little monads in my code would be affected. Also, Monad dictionaries would get slightly larger.
And the Haskell libraries already contain superclass relationships that make less sense than the Functor=>Monad relationship.
This is true. Here's some good background reading that Google turned up: http://www.cs.chalmers.se/~rjmh/Haskell/Messages/Display.cgi?id=444 I think this was part of the original Haskell 98 discussion. Cheers, Simon

Hello,
For a given type T which has a Monad instance, you can always declare
instance Functor T where fmap = liftM
so it is not a big burden to have to declare a Functor instance to accompany a Monad instance.
I don't really have a strong view about this, I'm happy to defer to those who know more about it. > But I have a slight preference for not having to define Functor instance if I don't need one - lots of > little monads in my code would be affected. Also, Monad dictionaries would get slightly larger.
These days I never define instances of the monad class, I use a library to create my monads. I don't know what these "little monads" you mention are, but it is very likely that you can make your programs smaller and more readable by simply using one of the monad libraries. The library already has instances for both "Monad" and "Functor" so you don't need to define any extra instances at all (not even "Monad" instances). Sadly because "Functor" is not a superclass of "Monad" if you have code that is plymorphic in the monad, and you don't try very hard to not use "fmap" (ah double negations!) you get extra constraints, that make the type signatures look scary and encourage people to not write them. -Iavor PS: I think John Peterson's post makes a lot of sense.

Simon Marlow wrote:
Here's some good background reading that Google turned up:
http://www.cs.chalmers.se/~rjmh/Haskell/Messages/Display.cgi?id=444
Interesting.
I think this was part of the original Haskell 98 discussion.
Yes. The message still appears under "Questions on the table", see http://www.cs.chalmers.se/~rjmh/Haskell/, so I guess no decision was made... I noted the following paragraph in particular: The "Functor a => Monad a" relationship is also "justifiable" because you can implement "map" using ">>=" and "return". I argued against having this relationship while on the Haskell 1.{3,4} committee - but I think that was a mistake. Perhaps the time has come to correct the mistake. -- Thomas H
participants (3)
-
Iavor Diatchki
-
Simon Marlow
-
Thomas Hallgren