On Tue, Dec 11, 2007 at 02:20:52PM +0000, Duncan Coutts wrote:
> I'd just like to float an idea that's related to the Class Alias
> proposal[1] but is perhaps somewhat simpler.
>
> We all know that Functor should have been a superclass of Monad, and
> indeed we now know that Applicative should be too. Making such a change
> would break lots of things however so the change does not happen.
>
> However in this case the Monad operations can be used to implement the
> Functor and Applicative class methods. So it would be nice if we could
> get them for free if the author did not choose to write the Functor and
> Applicative instances.
>
> So my suggestion is that we let classes declare default implementations
> of methods from super-classes.
>
> class Functor m => Monad m where
> {- the ordinary bits -}
>
> fmap f m = m >>= return . f
>
> So if there already is a Functor instance for m then the default
> implementation of fmap is not used.
>
>
> Does this proposal have any unintended consequences? I'm not sure.
> Please discuss :-)
>
> Duncan
>
> [1] http://repetae.net/recent/out/classalias.htmlThis is almost exactly the http://haskell.org/haskellwiki/Class_system_extension_proposal; that page has some discussion of implementation issues. Stefan
signature.asc
Description: Digital signature
_______________________________________________ Glasgow-haskell-users mailing list [email protected] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
