[Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

oleg at pobox.com oleg at pobox.com
Fri Dec 7 06:52:43 EST 2007

Philipp N. wrote:
> i'm trying to wrap functions (a -> b -> ... -> z) of any arity to functions
> of type ([String] -> y), where list of strings replaces the typed arguments.
> the problem is, that you cannot distinguish type (x->y) from z, so these
> instances are overlapping.

to which apfelmus replied
> Exactly. What you want to do is most likely impossible,

In fact, that distinction is possible. The following article

	How to write an instance for not-a-function

specifically describes a method of writing an instance which is
selected only when the type in question is NOT a function. The method
is quite general and has been extensively used (for example, to
implement deep monadic join).

More information about the Haskell-Cafe mailing list