<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 16, 2013 at 12:49 AM, Bryan Vicknair <span dir="ltr"><<a href="mailto:bryanvick@gmail.com" target="_blank">bryanvick@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div id=":1ik" style="overflow:hidden">
I guess it is because the literal '5' could be an Int or a Float, and the type<br>
system doesn't know.<br></div></blockquote><div><br></div><div>The literal '5' is *known* to be of the *polymorphic* type (Num a => a). Ints and Floats are monomorphic instances of this polymorphic type. See<br>
<br><a href="http://www.haskell.org/onlinereport/basic.html#numeric-literals">http://www.haskell.org/onlinereport/basic.html#numeric-literals</a><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div id=":1ik" style="overflow:hidden">
When I saw that the following does not work...::<br>
<br>
bar :: (Show a) => a<br>
bar = False<br>
<br>
...it made a bit more sense. It seems that if a literal can be considered part<br>
of a typeclass in more than one way, you can declare that literal to be of that<br>
typeclass. However, if there is only one way for a literal to belong to a<br>
typeclass, then you can't.</div></blockquote></div><br></div><div class="gmail_extra">The part "if a literal can be considered part of a typeclass in more than one way" isn't how you want to think about them (see link). Good attempt though.<br>
</div><div class="gmail_extra"><br>>
I don't have a need for this, but now I'm curious: is there a way to declare<br>
that all literal numbers in a module are of a certain concrete type? Something<br>
like -XAllNumbersAreInt8?<br><br></div><div class="gmail_extra">You enforce monomorphism by specifying type signatures where appropriate. In some cases, a light touch is all that's needed because type inference does the rest.<br>
</div><div class="gmail_extra"><br><div>-- Kim-Ee</div>
</div></div>