You may know, usually most of Haskell programmer use (.) operator to combine functions. However, it is not necessary. It can replace with (<*>) and const.
Prelude Control.Applicative> :t (.)
(.) :: (b -> c) -> (a -> b) -> a -> c
Prelude Control.Applicative> :t \x y z -> (const x <*> y) z
\x y z -> (const x <*> y) z :: (a -> b) -> (b1 -> a) -> b1 -> b
So anytime you want to use (.) operator, you can do it without (.)
Prelude Control.Applicative> (map . (+)) 1 [1, 2, 3]
[2,3,4]
Prelude Control.Applicative> (const map <*> (+)) 1 [1, 2, 3]
[2,3,4]
And it is also easy to remove points from float expression:
Prelude> 1.5
1.5
Prelude> 15e-1
1.5
The most biggest problem is how to remove this point.
import Control.Applicative
^
No comments:
Post a Comment