On Sun, 2010-11-28 at 22:59 +0800, Jafet wrote:
> > {-# LANGUAGE TypeSynonymInstances #-}
> > type Identity a = a
> > instance Applicative Identity where
> >   -- something like
> >   pure a = a
> >   f <*> a = f a
> 
> But GHC does not accept type synonym instances unless they are fully
> applied.
> 
> Is it sound for such an instance to exist? If so, how might it be
> defined? 

> data Tag a = Tag
>
> instance Applicative Tag where
>     pure _ = Tag
>     Tag <*> Tag = Tag
>
> cast :: Tag a -> Tag b
> cast Tag = Tag

1. pure id <*> Tag = Tag

2. I'm too lazy to prove it

3. pure f <*> pure x = Tag <*> Tag = Tag = pure (f x)

4. u <*> pure y = u <*> Tag = u = Tag <*> u = pure ($ y) <*> u

> x = pure undefined
> y = x :: Tag ()

Is y defined?

pure!Tag undefined = Tag
pure!Identity undefined = undefined

Regards

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to