[Haskell-cafe] function types as instances of Num

Dan Weston westondan at imageworks.com
Thu Oct 26 20:47:25 EDT 2006


You need to monomorphize the result before printing:

main = print $ ((square . 4) :: Alpha ())

Presumably you will apply (square . 4) at some point to a concrete state 
at some point, and you wouldn't need to provide the type explicitly.

Greg Buchholz wrote:
> 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)
> 
> Thanks,
> 
> Greg Buchholz
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 




More information about the Haskell-Cafe mailing list