[Haskell-cafe] Simple question about the function composition
operator
Miguel Mitrofanov
miguelimo38 at yandex.ru
Fri Sep 24 05:39:16 EDT 2010
(g . f) x y = (\z -> g (f z)) x y = g (f x) y, and you need g (f x y), which is definitely not the same thing.
24.09.2010 13:35, Axel Benz пишет:
>
> 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
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list