<div dir="ltr">On Wed, Dec 19, 2012 at 10:52 AM, Emanuel Koczwara <span dir="ltr">&lt;<a href="mailto:poczta@emanuelkoczwara.pl" target="_blank">poczta@emanuelkoczwara.pl</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If so, how are numbers defined? I can use 1 :: Int or 1 :: Integer. Why not Value1 :: MyType1 and Value1 :: MyType2?<br></blockquote><div><br></div><div>Numbers are special-cased in the compiler, because they&#39;re polymorphic; in effect, the literal is output as a call to &quot;fromIntegral&quot; or &quot;fromRational&quot; as appropriate for the type, on some low level internal representation of the literal.  (There is an extension to enable this for strings as well, but not for other types.)  You can&#39;t do this with user defined types because you can&#39;t make a constructor a typeclass function.</div>
<div><br></div><div>Note that various things, in particular pattern matching, rely on constructor names unambiguously identifying types.  (Again, numeric literals are a special case; patterns involving them actually get rewritten into guards.  If you want to know the gory details, they&#39;re documented in the Haskell Language Report.)</div>
</div><div><br></div>-- <br><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>
<div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div><br>
</div>