[Haskell-cafe] function types as instances of Num

Greg Buchholz haskell at sleepingsquirrel.org
Thu Oct 26 20:40:51 EDT 2006

Dan Weston wrote:
> How about:

    Hmm.  I'm probably being dense today, but when I add the following
definitions to your program... 

main = print $ (square . 4) ()
square (a,b) = (a*a,b)

...I still get the same error...

    No instance for (Num (() -> (t, t1)))
      arising from the literal `4' at weston.hs:5:25
    Possible fix: add an instance declaration for (Num (() -> (t, t1)))
    In the second argument of `(.)', namely `4'
    In the second argument of `($)', namely `(square . 4) ()'
    In the expression: print $ ((square . 4) ())

...maybe you could show me your implementation of "main" and "square" to
help nudge me in the right direction.  (I'm using ghc-6.6)


Greg Buchholz

More information about the Haskell-Cafe mailing list