I have a function here
(map (\ (a, b) -> dir a b) $ routes
where routes
is a list of tuples and it contains
routes = [...
("graph-fb", seeOther redirectUrlGraphEmail $ toResponse ""),
("post-fb", seeOther redirectUrlGraphPost $ toResponse ""),
...]
Here is the question: when I call this function to apply dir on each tuple, which function is going to be returned as b
in dir a b
first, the function seeOther redirectUrlGraphEmail
or seeOther redirectUrlGraphEmail $ toResponse ""
?
答案 0 :(得分:2)
Tuples items are separated by ,
which means that in your example for graph-fb
,
a == "graph-fb"
b == seeOther redirectUrlGraphEmail $ toResponse ""
The first function call to resolve will be toResponse ""
, and that will be fed into seeOther
as the second parameter. The result of this will then have the label b
inside the mapping function.
答案 1 :(得分:0)
There's no way to tell from that code. Even ignoring the compiler's freedom to reorganize your program in various dramatic ways, the usual approach to Haskell evaluation is lazy, which you can think of as demand-driven, case
-driven, and (ultimately) I/O-driven. Whoever actually inspects the results determines the evaluation order.