haskell - Why is the use of (>100) partial application? -


this code illustrates use of partial application through use of operator section :

gt100 :: integer -> bool gt100 x = x > 100   greaterthan100 :: [integer] -> [integer] greaterthan100 xs = filter gt100 xs  greaterthan100_2 :: [integer] -> [integer] greaterthan100_2 xs = filter (\x -> x > 100) xs   greaterthan100_3 :: [integer] -> [integer] greaterthan100_3 xs = filter (>100) xs 

the operator section (>100) partially applies operator 1 of 2 arguments. operator in case > why partial application > operator being applied entire integer list ?

how different lambda expression (\x -> x > 100) apparently not partial application ?

taken http://www.seas.upenn.edu/~cis194/spring13/lectures/04-higher-order.html

update :

thanks answers appears clearer.

so here understanding :

*main> :t (>) (>) :: ord => -> -> bool 

is not applied @ accepts 2 parameters "a -> a" not applied.

*main> :t (>100) (>100) :: (ord a, num a) => -> bool 

is partially applied function of type "a -> bool" created

*main> :t (3>100) (3>100) :: bool 

is evaluated type bool return type of operator (>) illustrated :t (>)

why partial application > operator being applied entire integer list ?

it not applied entire list, whole, individual elements, 1 one. when > partially applied on 100, creates new function.

prelude> :type (> 100) (> 100) :: (num a, ord a) => -> bool 

now, function accepts argument , returns bool. function applied elements in list filter function.


how different lambda expression (\x -> x > 100) apparently not partial application ?

> function needs 2 operands operate. passing 1 of them, 100. execute function, need 1 more argument. so, function > partially applied 100.

in second case, creating new function needs 1 argument execute. once pass argument, function executed. so, lambda function not applied partially.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -