[Haskell-cafe] Re: Overloading functions based on arguments?
John A. De Goes
john at n-brain.net
Sat Feb 14 10:10:25 EST 2009
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?
>
>
>
More information about the Haskell-Cafe
mailing list