RE: [Haskell-cafe] function types as instances of Num

2006-11-01 Thread Simon Peyton-Jones
Try test' = square . (4 :: a -> (Integer,a)) Otherwise, how is the compiler to know that you want 4 to be of that type? S | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg | Buchholz | Sent: 26 October 2006 18:46 | To: haskell-cafe@haskell.org |

Re: [Haskell-cafe] function types as instances of Num

2006-10-26 Thread Dan Weston
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:

Re: [Haskell-cafe] function types as instances of Num

2006-10-26 Thread Greg Buchholz
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 `

Re: [Haskell-cafe] function types as instances of Num

2006-10-26 Thread Dan Weston
How about: {-# OPTIONS -fglasgow-exts #-} import Control.Arrow type Alpha alpha = alpha -> (Integer,alpha) test = square . (lit 4) lit :: Integer -> Alpha alpha lit val stack= (val, stack) instance Eq (Alpha alpha) where x == y = uncurry (==) . (fst . x &&& fst . y) $ undefined insta