[Haskell-beginners] Re: Function composition with more than 1 parameter

Glurk streborg at hotmail.com
Sat Oct 25 09:57:38 EDT 2008

> > I'm using WinHugs - do you get them to work in some other environment ?
> Did you give a type signature for these?
> Then you would of course have to include the context Eq b, since (==) is 
> If you don't give any type signatures, all above versions should work in all 
> environments, otherwise it would be a serious bug.

OK, now I'm getting somwhere ! :)

I tried it with GHCi, and it works !
...but only after disabling the monomorphism restriction !
It offered another alternative, which was to give a type definition.

So, I tried :-

matches :: Eq a => a -> [a] -> [a]
matches = filter . (==)

hm :: Eq a => a -> [a] -> Int
hm = (length .) . matches

in Hugs, and that also worked :)

I'm still struggling to come to grips with how it is actually working...
I was thinking that this pointfree style was to make things simpler, more 
readable and understandable...but now I'm not so sure !

If it's not a simple case (f.g.h etc) I might just stick with putting the 
parameter names in. At this point, brackets and multiple dots like this don't 
really make things clearer to me (Not to mention John's post below, with 3 
consecutive dots ! I'm really having trouble with that one !). Of course, a 
lot of this is due to my lack of understanding - I'll keep experimenting and 
trying to learn :)

In general though, do people find this style clearer ?
I'd be interested to know what other people prefer.

Thanks for all the help :)

More information about the Beginners mailing list