<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>read "(3,'a')"::(Int, Char) returns expected tuple. But with "::
Int" leads to runtime exception, because it calls `readsPrec` of
Int and can not parse such string. But readsPrec of (a,b) where
both are readable parses it successfully. <br>
</p>
<br>
<div class="moz-cite-prefix">12.07.2018 13:05, mrx wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CANzOjBicRt1z9KyaFcwmy_0Wr=hd5CFNHLE1Eh=rsfGAfhbSmQ@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="ltr">
<div>Hi,</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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!</div>
<div><br>
</div>
<div>This is seeing Read as a function, as it's a type class i
suspect I'm missing something. Quite possibly quite a lot...</div>
<div><br>
</div>
<div>Why is the type class called `Read`?</div>
<div>What am I missing above?</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">// Patrik Iselind</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</body>
</html>