[Haskell-cafe] RLE in Haskell: why does the type variable get instantiated?

Chris Eidhof chris at eidhof.nl
Tue Jul 31 05:38:43 EDT 2007

Hey Haskell-Cafe,

I was trying out the code in Dons's article [1], and I noticed a  
weird thing when doing it in GHCi. When binding the function  
composition to a variable, the type suddenly changes. I'm not  
completely sure why this happens. Is this because GHCi is in a monad  
and wants to find an instance for the type variable? Here's my GHCi  

Prelude> :m +Control.Arrow
Prelude Control.Arrow> :m + List
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)]


[1]: http://cgi.cse.unsw.edu.au/~dons/blog/2007/07/31

More information about the Haskell-Cafe mailing list