newbie question regarding type declarations t.zielonka at
students.mimuw.edu.pl Fri Oct 31 13:08:54 EST 2003 On Fri, Oct
31, 2003 at 05:30:06PM +0550, gangadhar npk wrote: > I am a
newbie to Haskell. I am reading the tutorial by Hal Daume III.
Regarding the function types which are an extension of lambda
calculus, I was wondering if at all it is possible to write a
type that would return two values as the output - something like
a square function which would take a pair and return a pair. > I
tried this, but there are errors > square :: (Num a, Num b) =>
(a ,b) > square (x , y) = (x*x , y*y) > How can I specify that
the square functions output would be a pair ? You forgot about
function arguments in its type. It should be: square :: (Num a,
Num b) => (a, b) -> (a, b) Next time try commenting out the type
signature and see if the compiler can infer the type. Both Hugs
and GHCi provide commands for inspecting types of values.
Prelude> let square (x,y) = (x*x,y*y) Prelude> :type square
forall a a1. (Num a1, Num