[Haskell-cafe] Function composition

Tony Morris tmorris at tmorris.net
Fri Dec 26 23:06:09 EST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Check the type of (.)

Prelude> :t (.)
(.) :: (b -> c) -> (a -> b) -> a -> c

Then the type of (.) not

Prelude> :t (.) not
(.) not :: (a -> Bool) -> a -> Bool

Now try to apply (==)

Prelude> :t (.) not (==) -- not going to happen

Won't happen. What do you want to happen?


Oscar Picasso wrote:
> Hi,
>
> I can write:
> *Main> let yes = not . not
> *Main> :t yes
> yes :: Bool -> Bool
>
> But not:
> *Main> let isNotEqual = not . (==)
>
> <interactive>:1:23:
>     Couldn't match expected type `Bool'
>            against inferred type `a -> Bool'
>     Probable cause: `==' is applied to too few arguments
>     In the second argument of `(.)', namely `(==)'
>     In the expression: not . (==)
>
> Why?
>
> Oscar
>
>
> ----------------------------------------------------------------------
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

- --
Tony Morris
http://tmorris.net/

S, K and I ought to be enough for anybody.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJVamwmnpgrYe6r60RAnerAKDAs4KKsGHN7/WnqUYAJcVJixQiCgCgkQTV
CgeAJDTFEeKdAl4Ep3ibG88=
=GcLE
-----END PGP SIGNATURE-----



More information about the Haskell-Cafe mailing list