[Haskell-cafe] Data types a la carte

Sjoerd Visscher sjoerd at w3future.com
Wed Jul 21 17:58:46 EDT 2010

On Jul 21, 2010, at 11:25 AM, Victor Nazarov wrote:

> 1) UndecidableInstances are required for this code to compile.
> Is it possible to avoid this language extension? What is the
> reason for it to be required?

The rule "No type variable has more occurrences in the assertion than in the head" is violated with "instance Show (f (Mu f)) => Show (Mu f)". The head becomes larger, so ghc cannot tell that checking the assertions will terminate.

> 2) app, var, abs functions. app function is defined
> differently for every example. Is it possible
> to perform some automatic lifting so that app will work
> for any combination of ApplicativeF? Can I use Functor class
> or should I define my own type-class for this purpose? Is it
> possible at all?

Yes, it is possible, see the section "automating injections" in the Data Types A La Carte paper.

Sjoerd Visscher

More information about the Haskell-Cafe mailing list