
Hallo Can somebody tell me the type of the following function? func :: ????????????? func f x = (z,y) where (z,y) = f x Thanks -- View this message in context: http://www.nabble.com/Type-of-a-function--tf1945843.html#a5335607 Sent from the Haskell - Haskell-Cafe forum at Nabble.com.

Did you try putting this in a file, say, t.hs and running
ghci t.hs
then typing
:type func
at the GHCi prompt? It should tell you the function type.
Jared.
On 7/14/06, Jenny678
Hallo
Can somebody tell me the type of the following function?
func :: ????????????? func f x = (z,y) where (z,y) = f x
Thanks -- View this message in context: http://www.nabble.com/Type-of-a-function--tf1945843.html#a5335607 Sent from the Haskell - Haskell-Cafe forum at Nabble.com.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- http://www.updike.org/~jared/ reverse ")-:"

(leave off the line with
func :: ???????????????
and the compiler will figure it out for you, if possible---it works in
this case)
Jared.
On 7/14/06, Jared Updike
Did you try putting this in a file, say, t.hs and running ghci t.hs
then typing
:type func
at the GHCi prompt? It should tell you the function type.
Jared.
On 7/14/06, Jenny678
wrote: Hallo
Can somebody tell me the type of the following function?
func :: ????????????? func f x = (z,y) where (z,y) = f x
Thanks -- View this message in context: http://www.nabble.com/Type-of-a-function--tf1945843.html#a5335607 Sent from the Haskell - Haskell-Cafe forum at Nabble.com.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- http://www.updike.org/~jared/ reverse ")-:"

On 7/14/06, Jenny678
Hallo
Can somebody tell me the type of the following function?
func :: ????????????? func f x = (z,y) where (z,y) = f x
Let's try to reason about it. Let's start with some approximation to the type of 'func'. It appears to take two parameters so we'll say, func :: a -> b -> c Now we look at the first parameter, f, and see that it can be applied to x to get a tuple. f :: b -> (d, e) Now we can replace the the type variable 'a' with the signature for f. func :: (b -> (d, e)) -> b -> c But we also notice that the type (d, e) which is returned by f is also returned by func. func :: (b -> (d, e)) -> b -> (d, e) So there you have it. That's how you can reason about types. (and hopefully I didn't make a clerical error...) HTH, Jason
participants (3)
-
Jared Updike
-
Jason Dagit
-
Jenny678