[Haskell-cafe] Function Type Calculation (Take 2)

PR Stanley prstanley at ntlworld.com
Sun Apr 27 16:16:24 EDT 2008


In case you missed it the first time here is my query again:
Hi
I know we've already looked at the topic of function type calculation 
though last time I didn't have the chance to go through it 
thoroughly. So here it is again. Apologies for the repetition. I've 
had a try at calculating function types for two examples below. So to 
start with I'd be grateful for an assessment of my efforts. All 
comments are welcome.
Thanks,
Paul

			[1]
funk f x = f (funk f) x

	f :: a
	x :: b
	funk f x :: c
therefore funk :: a -> b -> c

		RHS
	f (funk f) x :: c

	f (funk f) :: d -> c
	x :: d

	f :: e -> d -> c

	funk :: h -> e
	f :: h

		unification
	f :: a = h = (e -> d -> c)
	x b = d

therefore funk :: ((h -> e) -> b -> c) -> b -> c

			[2]
w f = f f

Assigning Types
	f :: a
	w f :: b
therefore w :: a -> b

		RHS
	f f :: b

	f :: c -> b
	f :: c

	f :: a = b = c = (c -> b)

therefore w :: (a -> a) -> a



More information about the Haskell-Cafe mailing list