[Ur] Implicit problem in typeclass recursive instance [testable t] -> testable (list t)
Gabriel Riba
griba2001 at gmail.com
Mon Jan 19 14:33:42 EST 2015
Gabriel Riba <griba2001 <at> gmail.com> writes:
>
> Hi!
>
> Here is the code:
>
> (* --- *)
>
> fun id [a] (x: a): a = x
>
> type assertion = transaction xbody
>
> datatype test = Test of assertion | TestList of (list test)
>
> (* class *)
> con testable t = {TestIt: t -> test}
> fun mkTestable [t] (f: t -> test): testable t = {TestIt = f}
> val testIt [t] (r: testable t): (t -> test) = r.TestIt
>
> (* instances *)
> val testable_test: testable test = mkTestable id
>
> val testable_testList [t] (_: testable t): testable (list t) =
> let
> fun testIt' (t1: list t): test =
> TestList (List.mp testIt t1) (* line with error *)
> in mkTestable testIt'
> end
>
> (* --- *)
>
Workaround: make the parameter explicit (it compiles now):
val testable_testList[t] (r: testable t): testable (list t) =
let
fun testIt' (tlist: list t): test =
TestList (List.mp (testIt r) tlist)
in mkTestable testIt'
end
More information about the Ur
mailing list