<div dir="ltr">On Fri, Aug 12, 2011 at 18:52, Patrick Browne <span dir="ltr">&lt;<a href="mailto:patrick.browne@dit.ie">patrick.browne@dit.ie</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;">
Why does the Haskell :type command only sometimes print the type-class?<br>
</blockquote><div><br></div><div>Haskell infers the most specific type applicable. If the most specific it can get is a typeclass, that&#39;s what it produces; if it can infer an explicit type, it will.</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Should I expect type-class inference as well as type inference?<br>
Maybe the type-class is inferred where possible, but not always printed?<br></blockquote><div><br></div><div>Typeclasses are not independent of types, and are not inferred separately from types. If you want to know what typeclasses a type is a member of, use :info.</div>
<div><br></div><div>Haskell supports polymorphism: a bound expression does not need to have a single specific type, it can apply to multiple types and adapt itself to the type at its use site. Typeclasses are part of how this is accomplished. So if a bound expression is polymorphic, you will see its type expressed in terms of type variables, possibly with typeclass contexts.</div>
<div><br></div></div>-- <br>brandon s allbery <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a><br>wandering unix systems administrator (available) (412) 475-9364 vm/sms<br>
<br>
</div>