Consider:
class RT r t where rt :: r -> t
data D t = Dt t | forall r. RT r t => Dr r
f1 :: D t -> D t
f1 (Dr r) = Dt (rt r)
f2 :: D t -> D t
f2 = g
where g :: D t -> D t
g (Dr r) = Dt (rt r)
Your explanation well justifies the need for `f1`'s type declaration. But I
still don't unders
Because you could have an instance:
instance RT r t1
and another instance for a t2 /= t1:
instance RT r t2
then when you say:
g (Dr r) = Dt (r t)
then, 'r t' could either have type t1 or t2, thus giving the result value
type 'Dt t1' or 'Dt t2'.
If your class had fundeps 'r -> t', then
Can someone explain why the type declaration for `g` is required in the
following?
class RT r t where rt :: r -> t
data D t = Dt t | forall r. RT r t => Dr r
f :: D t -> D t
f = g
where -- g :: D t -> D t
g (Dr r) = Dt (rt r)
As given above, the program evokes these error messages:
w