
7 Dec
2007
7 Dec
'07
6:52 a.m.
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 http://okmij.org/ftp/Haskell/typecast.html#is-function-type 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).