[Haskell-beginners] Ambiguous type error: multiparam class + type alias
Baa
aquagnu at gmail.com
Thu Sep 28 13:30:19 UTC 2017
> You could also avoid all this ambiguity/type application stuff with:
> data AsTitle = AsTitle
> class Repr a b where
> repr :: a -> b -> Repr b
> instance Repr Int AsTitle where
> repr n _ = ...
> ...
> print (repr n AsTitle)
Yes, "moving" of type from the right-side (result) to the left-side
(arguments) solves the problem, sure.
> (Repr b can be an associated type if you want to support different
> representations)
>
> >
> >> You only add a constraint as follows:
> >> repr n :: forall b. (Repr b ~ Repr AsTitle, ReprC Int b) => Repr
> >> b
> > Yes... So, `b` is unbound/free type param. But I can bind it with
> > func. deps, yes?
> How? If you you bind it with a functional dependency on "a", you can
> only have a single "b" for each "a".
I don't know... I wrote to David my idea - additional param on the
left-side of func. dependency, but how/what param?
===
Best regards, Paul
More information about the Beginners
mailing list