
Tony Morris wrote:
is the same as: (.) :: (b -> c) -> ((a -> b) -> (a -> c)) .. "accepts a function a to c and returns a function. The function returned takes a function a to b and returns a function a to c"
IMO, that should be "accepts a function b to c and returns a function. The function returned takes a function a to b and returns function a to c" Personally I also find the following a good explanation, since it does not introduce lambdas or other scary things for newbies. f . g = composite where composite x = f (g x) for example printLn = putStrLn . show so printLn x becomes putStrLn (show x) Cheers, Peter
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Apply parentheses from the right.
So: (.) :: (b -> c) -> (a -> b) -> a -> c
is the same as:
(.) :: (b -> c) -> (a -> b) -> (a -> c)
is the same as: (.) :: (b -> c) -> ((a -> b) -> (a -> c))
How you read that is up to you, but here is one way of reading it:
"accepts a function a to c and returns a function. The function returned takes a function a to b and returns a function a to c"
The expression f(g(x)) in C-style languages is similar to (f . g) x
Tony Morris http://tmorris.net/
PR Stanley wrote:
Hi (.) :: (b -> c) -> (a -> b) -> (a -> c) While I understand the purpose and the semantics of the (.) operator I'm not sure about the above definition. Is the definition interpreted sequentially - (.) is a fun taht takes a fun of type (b -> c) and returns another fun of type (a -> b) etc? Any ideas? Thanks, Paul
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFG9JzXmnpgrYe6r60RAjDrAJ0SvkZHtNsctWNYHjqxjp9lnpNvgACfS/2r 9jwUvD29/ZMMot8x3/nvyI8= =xSzA -----END PGP SIGNATURE----- _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe