0

我这里有一个功能

(map (\ (a, b) -> dir a b) $ routes 

whereroutes是一个元组列表,它包含

routes = [...
           ("graph-fb", seeOther redirectUrlGraphEmail $ toResponse ""),
           ("post-fb", seeOther redirectUrlGraphPost $ toResponse ""),
          ...]

这里是一个问题:当我调用这个函数在每个元组上应用 dir 时,哪个函数将像第一个那样返回bdir a b函数seeOther redirectUrlGraphEmail还是seeOther redirectUrlGraphEmail $ toResponse ""

4

2 回答 2

2

元组项目是分开的,,这意味着在您的示例中graph-fb

a == "graph-fb"
b == seeOther redirectUrlGraphEmail $ toResponse ""

解析的第一个函数调用将是toResponse "",并将seeOther作为第二个参数输入。然后,此结果将b在映射函数内具有标签。

于 2016-08-31T17:10:37.023 回答
0

没有办法从该代码中分辨出来。即使忽略编译器以各种戏剧性方式重组程序的自由,Haskell 评估的常用方法也是惰性的,您可以将其视为需求驱动、-case驱动和(最终)I/O 驱动。实际检查结果的人确定评估顺序。

于 2016-09-01T06:10:47.330 回答