[Haskell-cafe] noob question

Philippa Cowderoy flippa at flippac.org
Mon Feb 25 19:11:55 EST 2008


On Mon, 25 Feb 2008, Ben wrote:

> <interactive>:1:8:
>    Ambiguous type variable `t' in the constraints:
>      `Fractional t' arising from a use of `/' at <interactive>:1:8-10
>      `Integral t' arising from a use of `^' at <interactive>:1:7-15
>    Probable fix: add a type signature that fixes these type variable(s)
> 

/ doesn't do integer division, so from there it concludes that you're 
working with a Fractional type - Haskell never coerces behind your back, 
so not only the result of / but also its parameters are Fractional. 

^ only works for Integral types. You might consider that a little 
arbitrary, but hey - it's mostly like that because it's much easier to 
raise something to an integer power.

There's no default it can pick that's both Fractional and Integral, so it 
doesn't know what type the expression should have and it's asking you to 
tell it ("add a type signature that fixes these type variable(s)"). In 
practice you won't be able to unless you've got a broken number type 
handy, but that's the way things go.

-- 
flippa at flippac.org

Sometimes you gotta fight fire with fire. Most
of the time you just get burnt worse though.


More information about the Haskell-Cafe mailing list