Simon Peyton-Jones wrote:

b) having instance declarations silently spring into existence

Concerning (b) here's a suggestion.  As now, require that every instance
requires an instance declaration.  So, in the main example of
http://haskell.org/haskellwiki/Class_system_extension_proposal, for a new
data type T you'd write

        instance Monad T where
          return = ...
          (>>=)  = ...

        instance Functor T
        instance Applicative T

Without the automatic search, this is already possible

    class Functor f where
        fmap :: (a -> b) -> f a -> f b

    class Functor m => Monad m where
        return :: a -> m a
        (>>=)  :: m a -> (a -> m b) -> m b

       -- aka liftM
    fmapDefault :: Monad m => (a -> b) -> m a -> m b
    fmapDefault f m = m >>= (return . f)

    instance Monad [] where
        return x = [x]
        (>>=)    = flip concatMap

    instance Functor [] where
        fmap = fmapDefault

fmap is already written for you, the instance declaration is only boilerplate. I first saw this in Data.Traversable .


Regards,
apfelmus

_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to