Take, for example, this function:

f :: [Char] -> Char

f []     = chr 0
f (c:cs) = chr (ord c + ord (f cs))

[] is typed as [Char], even though it could be typed in infinitely many other ways. Demonstrating yet again, that the compiler *does* use the additional information that it gathers to assist with typing.

Regards,

John A. De Goes
N-BRAIN, Inc.
The Evolution of Collaboration

http://www.n-brain.net    |    877-376-2724 x 101

On Feb 13, 2009, at 6:31 PM, Robert Greayer wrote:

-- John A. De Goes wrote:

Adding information cannot remove a contradiction from the information
set available to the compiler.

But it can and often does, for example, for [] or 4. What's the type of either expression without more information?

[] :: [a]

4 :: Num a => a

Do I win something?




_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to