[Haskell-cafe] Transparent identity instances
Erik Hesselink
hesselink at gmail.com
Sun Nov 28 19:18:43 CET 2010
On Sun, Nov 28, 2010 at 15:59, Jafet <jafet.vixle at gmail.com> wrote:
> But using this instance becomes unwieldy. If using Identity was
> transparent, eg. if it was a type synonym
>
>> {-# 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?
Type synonym instances are nothing special, they are just shorthand
for writing an instance for the type they are a synonym for. So an
instance for 'Identity a' would actually be an instance for 'a' (which
isn't such a good idea). An instance for 'Identity' is indeed not
possible.
Erik
More information about the Haskell-Cafe
mailing list