[Haskell-beginners] question on types
Jake Penton
djp at arqux.com
Fri Jul 29 17:02:26 CEST 2011
On 2011-07-29, at 10:02 AM, Daniel Seidel wrote:
> On Fri, 2011-07-29 at 09:49 -0400, Jake Penton wrote:
>> For example, this does not compile:
>>
>> f :: Fractional a => a
>> f = 3.14
>
> I can load this to ghci and also compile
>
Yeah, sorry - so can I. I must have screwed up earlier. Fat fingers, bleary eyes....
But, getting back to my point (or possibly making an unrelated one for all I know), how about this, which I *hope* I am right in saying does NOT compile, even though Bool is an instance of Ord:
g :: Ord a => a
g = True
It still seems to me that the mere presence of a constraint does not make a difference by itself. Does the difference here lie in compiler calls to fromFractional or fromIntegral in appropriate cases?
- J -
More information about the Beginners
mailing list