24 Sep 19:17 2013

## Why superclass' instances are bad idea?

Wvv <vitea3v <at> rambler.ru>

2013-09-24 17:17:34 GMT

2013-09-24 17:17:34 GMT

I suggest to add superclass' instances into libraries. http://ghc.haskell.org/trac/ghc/ticket/8348 In brief, we could write next: >{-# LANGUAGE FlexibleInstances #-} >{-# LANGUAGE UndecidableInstances #-} > >instance Monad m => Applicative m where > pure = return > (<*>) = ap > >instance Monad m => Functor m where > fmap = liftM > >instance Monad m => Bind m where > (>>-) = flip (>>=) > B.join = M.join this code is valid! I've already defined 3 "superclassses" for Monad: Functor, Applicative and Bind! Similar idea said Edward Kmett in 2010 (founded by monoidal) ( http://stackoverflow.com/questions/3213490/how-do-i-write-if-typeclass-a-then-a-is-also-an-instance-of-b-by-this-definit/3216937#3216937 ) And he said "but effectively what this instance is saying is that every(Continue reading)