length xs > 15) (map chain [1..10...">

Vaguely about this use of lambda

So, I think of Lambdas, as shown in "Learn You a Haskell":

(filter (\xs -> length xs > 15) (map chain [1..100])) 

Input for xs is a list generated from (map chain [1..100])) This is fairly easy to read.

So, here, where I got confused, I look at some real world code (tm).

Here is the function from conduit

fmap f (ResourceT m) = ResourceT $ \r -> fmap f (m r)

Where is the input for r introduced?

+5
source share
2 answers

rwill not matter until the function \r -> fmap f (m r)is called. In a definition, a fmapfunction is never called - it is stored only in ResourceT. Then it can be removed from ResourceTand called out. This is when it rgets the value.

+12
source

\r -> fmap f (m r) - , closure. f m , . , Haskell , , .

+6

All Articles