
On Tue, May 26, 2015 at 8:35 PM,
Is there any way (without IncoherentInstances or Rebindablesyntax) that I can let the user write e.g. "giveGPA 4.0" (and "giveGPA 4") and get back "F 4" without getting type errors that "4.0"'s type is ambiguous? I can guarantee there won't be any additional instances to "ToGPA"
A typeclass with only one instance is nonsensical, and often a symptom of trying to use typeclasses as OO classes. All it's doing here is hurting you. In this case, you don't really want to do anything special at all: giveGPA :: Float -> GPA giveGPA f = F f and let Haskell's numeric overloading resolve 4 as (fromInteger 4 :: Float). (Use of the typeclass blocks this.) -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net