Narrower (per-method) GND

David Feuer david.feuer at gmail.com
Mon Jan 9 22:11:31 UTC 2017


On Mon, Jan 9, 2017 at 1:32 PM, Richard Eisenberg <rae at cs.brynmawr.edu> wrote:

> 2. Defaulting to the implementation written in the class (or `error
> "undefined method"` in the absence of a default. This is essentially the
> default default.)

I want to be able to specify that a certain default definition is good
enough not to worry about. For example (with horribly bad syntax),

class Applicative m => Monad m where
  (>>=) :: m a -> (a -> m b) -> m b
  m >>= f = join (f <$> m)  -- plain old default

  join :: m (m a) -> m a
  good_enough_default join = (>>= id)

This would allow users to just write

newtype Foo a = Foo ... deriving Monad

which would then be equivalent (using the notation you came up with) to

instance Monad Foo where
  deriving newtype (>>=)

David Feuer


More information about the Glasgow-haskell-users mailing list