On Jul 31, 2007, at 6:00 , apfelmus wrote:

Chris Eidhof wrote:
When binding the function composition to a variable, the type
suddenly changes.

Prelude Control.Arrow List> :t map (length &&& head) . group
map (length &&& head) . group :: (Eq a) => [a] -> [(Int, a)]
Prelude Control.Arrow List> let encode = map (length &&& head) . group
Prelude Control.Arrow List> :t encode
encode :: [Integer] -> [(Int, Integer)]

In short, you have to supply a type signature

  encode :: (Eq a) => [a] -> [(Int, a)]
  encode = map (length &&& head) . group

Note that you can do this at the GHCi prompt like this:

> let encode :: (Eq a) => [a] -> [(Int,a)]; encode = map (length &&& head) . group

since you can't use multi-line declarations from the prompt.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon university    KF8NH


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to