Proposal: merge either into transformers

Edward A Kmett ekmett at gmail.com
Sun Dec 9 02:38:59 CET 2012


I have a prelude-extras package that I use for 'bound' which contains those Eq1, Show1, etc classes. 

(As an unrelated aside bound packages up the generalized de Bruijn indices you did with Hinze as a reusable Haskell 98 monad transformer, you may find it interesting.)

Sent from my iPhone

On Dec 8, 2012, at 8:24 PM, Ross Paterson <ross at soi.city.ac.uk> wrote:

> On Sat, Dec 08, 2012 at 10:55:45PM +0000, Henning Thielemann wrote:
>> 
>> On Fri, 7 Dec 2012, Edward Kmett wrote:
>> 
>>> I will be sad to see those instances go, but I'm also +1
>> 
>> How about:
>> 
>> import Prelude hiding (Show, showsPrec)
>> import qualified Prelude as P
>> 
>> class Show m where
>>   showsPrec :: (P.Show e, P.Show a) => Int -> m (Either e a) -> ShowS
>> 
>> instance (Show m, P.Show e, P.Show a) => P.Show (EitherT e m a) where
>>   showsPrec d (EitherT m) = showParen (d > 10) $
>>     showString "EitherT " . showsPrec 11 m
> 
> A more economical variation on this idea would be to lift these classes
> to functors, e.g.
> 
> class ShowF f where
>    showsPrecF :: Show a => Int -> f a -> ShowS
> 
> instance (ShowF m, Show e, Show a) => Show (EitherT e m a) where
>    showsPrec d (EitherT m) = showParen (d > 10) $
>        showString "EitherT " . showsPrecF 11 m
> 
> instance (ShowF m, Show e) => ShowF (EitherT e m) where
>    showsPrecF = showsPrec
> 
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries



More information about the Libraries mailing list