varying number of arguments restriction
Tue, 30 Oct 2001 19:01:22 GMT
I'm curious why the following code is invalid (from a language design
point of view):
> foo :: [(Int, String)] -> String
> foo  = ""
> foo = snd . head
Varying number of arguments for function `foo'
I don't understand why this should be invalid? Basically, as I read
it, I say, well, for a parameter s, calling foo s:
does s match  ? if so, return "" otherwise, try the next definition
of foo (which must match in this case).
obviously i can rewrite:
foo  = ""
foo s = (snd . head) s
but this is uglier.
Hal Daume III
"Computer science is no more about computers | email@example.com
than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume