The following code, which is taken from Apocalisp\'s excellent blog series: Type level programming in scala , and modified for an implicit parsing scenario. However, this d
Although i can't tell you exactly the purpose of Predef.conforms
, i can tell you the ambiguity error seems correct (unfortunately). In the comment in the source it even says that <:<
was introduced because of ambiguity problems of Function1
(says Function2
but i guess that is a mistake). But since <:<
is a subclass of Function1
it can be passed in whenever Function1
is expected, so in your case its possible to pass in <:<
to hparse.
Now the implicit def conforms[A]: A <:< A
has the effect (from what i understand) that whenever a method expects a type A => A
, it is sufficient to have an implicit value of A
in scope.
In your case the implicit def hParseNil: HNil => HNil
has the same priority as conforms
and thus both could be equally applied.
I see two possible solutions:
hParseNil
, i think your code still works.shadow the Predef
's conforms
by naming yours the same:
implicit def conforms: HNil => HNil = _ => new HNil