[Haskell-beginners] question on types

Brandon Allbery allbery.b at gmail.com
Fri Jul 29 18:21:17 CEST 2011


It's true but incomplete:  the implicit fromIntegral is what enables
the numeric example to produce any numeric type, whike the Num
constraint just announces that fact.  The constraint itself is a
contract; fromIntegral is what delivers on the contract.

On 2011-07-29, Jake Penton <djp at arqux.com> wrote:
>
> On 2011-07-29, at 11:22 AM, Brandon Allbery wrote:
>
>> Ask yourself this: is True *every* instance of Ord?  You are expecting
>> it to be an "any", but it's an "every" (forall).
>>
>> By the way, True happens to be an instance of Ord but it doesn't have
>> to be.  You're working backwards here, I think.  It happens that
>> useful operations on things in class Ord generally produce Bool; that
>> doesn't mean Bool must be Ord.
>>
>
> Right - actually, I did not expect it to compile. I gave the code as,
> perhaps, a counterexample to what some other responses seemed to be
> asserting, although it is possible I did not get their point(s) correctly.
> They seemed to say that adding a constraint is of itself what makes the
> cases that used numeric literals work. But it seems (as described in Brent
> Yorgey's post) that there is more to it than that.
>
> - J -
>
>


-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms



More information about the Beginners mailing list