使用Elm 0.17,我有时希望看到在计算过程中所采取的步骤,例如:
let
names = Debug.log "accounts"
List.map (\x -> x.name) accounts
sortedNames = Debug.log "sorted accounts"
List.sortBy String.toLower names
options =
List.map (viewAccountOption selectedName) sortedNames
in
[ viewEmptyOption ] ++ options这将记录如下:
accounts: <function>
sorted accounts: <function:sortBy>我知道Elm很懒,当实际需要这些值时,就会对这些块进行评估。
我在force或strict函数中找不到榆树芯基,也找不到包中的其他地方。
是否有办法强制评估某一价值?
发布于 2016-06-09 15:02:27
您可以通过使用括号来做到这一点:
Debug.log "accounts"
(List.map (\x -> x.name) accounts)或使用<|运算符
Debug.log "accounts" <|
List.map (\x -> x.name) accounts编辑:
原因是Debug.log是以List.map (一个函数)作为第二个参数进行计算的,然后返回该参数以与行的其余部分组合。你只需要给埃尔姆一点暗示你的论点优先顺序是什么
https://stackoverflow.com/questions/37729430
复制相似问题