
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 7/26/10 07:30 , dan portin wrote:
I'm still a Haskell newbie, so take this with a grain of salt: the type signature of /foldr/ and /foldr1/ confuses me also. While I understand how each operates, I've never found a description of the type signatures of either functions which explains why the function argument of /foldr1/ is of type (a -> a -> a) instead of (a -> b -> b). This is the conclusion I came
foldr1 is just foldr where "z" is taken off the end of the list. Therefore, given [a] as the list type, b (the type of z) unifies with a; and since the folding function is initially called with z along with the first element of the list, (a -> b -> b), in the case of foldr1 it is forced to (a -> a -> a). - -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxNptUACgkQIn7hlCsL25VwrACgkTamfkChSLoWYJUuqXL3vYEs OMoAoMsJwZHf1of5uBQB7/iUSYjZuyC3 =DF5B -----END PGP SIGNATURE-----