[Haskell-beginners] Explicit specification of function types
bugfact at gmail.com
Tue Mar 24 19:02:55 EDT 2009
2009/3/24 Brandon S. Allbery KF8NH <allbery at ece.cmu.edu>
> That's my understanding, F++ types don't require any runtime lookups so
> inference can't surprise you.
It uses .NET interfaces for that, but the F# expert book mentions they would
like to have type classes in a future version of the language.
> in Haskell can do unexpected things: F++ has parenthesized function
> arguments, so it will catch too few/too many arguments directly, but
> Haskell's uncurried function call notation almost guarantees strange errors
> in those cases even if you have everything explicitly typed.
Not really, F# has both curried and uncurried forms, just like Haskell.
It is true that F# encourages automatic generalization without type
signatures. You never need to give one, even for exported modules.
But the lack of type classes has its price. E.g.
add x y = x + y
What is the type of add in F#?
Well, that depends on the first usage of this function... Give it Ints and
it becomes add :: Int -> Int -> Int, and you can't use it on Doubles any
more. Very confusing, since you can use the overloaded (+) on any type.
These are current limitations of the language.
At least that what I understood from it...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners