akg

akg akg

Niner since 2009

Comments

  • C9 Lectures: Dr. Erik Meijer - Functional Programming ​Fundamental​s, Chapter 3 of 13

    I loaded an haskell file with following code on hugs:

     

    double x = x + x
    quad x = double (double x)
    quadrup = double . double

     

    If I try "quad 1.01" (without quotes), the correct result of 4.04 is returned but if I try "quadrup 1.01" (without quotes) hugs returns following error message.

     

    ERROR - Cannot infer instance

    *** Instance : Fractional Integer

    *** Expression : quadrup 1.01

     

    Hugs returns the following types for quad and quadrup.

     

    Main> :type quad
    quad :: Num a => a -> a
    Main> :type quadrup
    quadrup :: Integer -> Integer

     

    Why does quadrup end up with type of Integer -> Integer instead of "Num a => a -> a" ?