[Haskell-cafe] Simple question about the function composition operator

Axel Benz axel.benz at vodafone.de
Fri Sep 24 05:35:00 EDT 2010


Hello,

 

this is maybe a simple question:

 

 

cbinary :: a -> b -> (a -> b -> b) -> (b -> c) -> c

 

-- Version 1 works:

 

cbinary x y f g = g (f x y)

 

-- Version 2 should be exactly the same according

-- to my understanding of the "." operator definition,

-- but fails with: 

--  Occurs check: cannot construct the infinite type: b = b -> b

--  When generalising the type(s) for `cbinary'

 

-- cbinary x y f g = (g . f) x y

 

 

Can anybody explain why this happens and how I can compose f and g?

Hint: It works fine if f is defined as an unary function.

 

Thank you very much!

 

Axel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100924/6fae9b0c/attachment.html


More information about the Haskell-Cafe mailing list