[Haskell-beginners] The type class Read

mrx patrik.mrx at gmail.com
Thu Jul 12 10:05:52 UTC 2018


Hi,

I'm trying to make sense of the type class `Read`. It feels to be like a
function performing casting to me, similar to what you have in C and Java.

The weird thing is that the casting doesn't have to make sense, type-wise.
So `read "5" :: Int` produce the integer 5 which make sense but `read
"(3,'a')" :: Int` doesn't make sense to me but ghci accepts it!

This is seeing Read as a function, as it's a type class i suspect I'm
missing something. Quite possibly quite a lot...

Why is the type class called `Read`?
What am I missing above?

// Patrik Iselind
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180712/24086d45/attachment.html>


More information about the Beginners mailing list