I'm curious why the following code is invalid (from a language design
point of view):

> foo :: [(Int, String)] -> String
> foo [] = ""
> foo = snd . head

ghc complains:

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

-- 
Hal Daume III

 "Computer science is no more about computers    | [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to