[Haskell-beginners] Question about define my own typeclass

Brandon Allbery allbery.b at gmail.com
Thu Mar 27 15:36:16 UTC 2014


On Thu, Mar 27, 2014 at 11:28 AM, ke dou <kd6ck at 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 at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140327/a1ed90dd/attachment.html>


More information about the Beginners mailing list