[Haskell-cafe] pointfree-trouble

Daniel Fischer daniel.is.fischer at web.de
Wed Dec 23 10:58:31 EST 2009


Am Mittwoch 23 Dezember 2009 14:40:46 schrieb slemi:
> i dont know any calculus-thingy, this is what i did:
>
> reMatr a = Matr . a . unMatr
> reMatr a = Matr . (. unMatr) a
> reMatr a = Matr . (flip (.) unMatr) a

You need to be aware of the implicit parentheses, that is

Matr . ((flip (.) unMatr) a)

or

(.) Matr ((flip (.) unMatr) a)

= ((.) Matr) ((flip (.) unMatr) a)

= f (g x), with

f = (.) Matr
g = flip (.) unMatr
x = a

Now f (g x) = (f . g) x and you're done.

But as Kim-Ee Yeoh pointed out, if you're pointfreeing, give type signatures, or the 
monomorphism restriction is going to surprise you some time.

> reMatr = Matr . (flip (.) unMatr)



More information about the Haskell-Cafe mailing list