opensubscriber
   Find in this group all groups
 
Unknown more information…

g : glasgow-haskell-users@haskell.org 5 March 2012 • 8:14PM -0500

Re: How to declare polymorphic instances for higher-kinded types?
by Herbert Valerio Riedel

REPLY TO AUTHOR
 
REPLY TO GROUP




Andres Löh <andres@well...> writes:

> Here's a way that seems to work for me. I haven't tested in detail.
> There may be problems, or also easier ways to achieve the same. The
> DataKinds extension isn't essential. I've just used it for fun.

looks interesting

If I get it right, the trick is to use a *-kinded (instead of a
*->*-kinded) argument for the class & instances and have a "type
function" that is able to phantom-retag an already applied
type-constructor `Foo_ Unres` to a differently applied type-constructor
`Foo_ Res`.

The only thing that disturbs me is that I have to define explicit
boilerplate type family declarations for all twenty or so
non-polymorphic instances which'd look always the same, i.e.

type ResFun (t r) a = t a
type ResArg (t r) a = t ~ a

...could that be defined as an override-able default somehow?

cheers,
hvr
--

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@hask...
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.