Thanks for your reply.

Yes, I understand that if I specify the 'b' to 'Prelude.Bool', it should work, but what if I also want use the typeclass Conversion to convert other types other than MyBool, like MyInt, or MyString?

--Ke

On Thu, Mar 27, 2014 at 11:36 AM, Brandon Allbery <allbery.b@gmail.com> wrote:
On Thu, Mar 27, 2014 at 11:28 AM, ke dou <kd6ck@virginia.edu> wrote:
    class Conversion a where
        conversion :: a  -> b

b is completely unspecified here, since it's not defined as part of the typeclass. The literal meaning of this is that "the caller can request any type it pleases, and you have no way of knowing what it is". So the only possible result of `conversion` is bottom (e.g. `undefined`).

This is key: it does NOT mean that `conversion` gets to specify the result type! You can't do that, except by specifying the type in the type signature.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners