[Haskell-cafe] ambiguous constraint errors

Isaac Dupree isaacdupree at charter.net
Thu May 29 16:25:34 EDT 2008


Evan Laforge wrote:
>>> get_int sym = fmap ambi_int (lookup sym ambi_table :: Maybe (Ambi Maybe))
>> Of you and the type system you're the only one who knows that that value is
>> not used. The type system doesn't use (all) the rules you have in your mind.
>> It follows more simple ones.
>>
>> You judge by values, not only types here. That is, you look at the value of
>> ambi_int and see that it's just 10 in your (value again) some_ambi. You see
>> that it's not
>>
>> ambi_int = (some_return_from_monad ambi_monad) * 3
> 
> I'm not totally understanding, but I think you're saying that I could
> write ambi_int in a way that it still had type "Ambi m -> Int" but
> depended on the type of 'm'.  I guess that makes sense, because it
> could "run" m internally and return an Int based on the result, which
> therefore depends on the type of 'm'.

It's more obvious with other type classes.

e.g. the snd of a value of type
(Num a) => (a, Bool)

Because what if the record/tuple was:
canOverflow = (ridiculous, ridiculous <= 4000000000)
   ridiculous = 4000000000 ^ 5

Then it depends on whether you pick Int or Integer (or something else) 
for "a", even if you only look at the Bool.


-Isaac


More information about the Haskell-Cafe mailing list