dum*_*mb0 3 haskell pointfree maybe
为什么这样做......
Just.(+3) $ 6.7
Just $ truncate 8.9
Run Code Online (Sandbox Code Playgroud)
......但不是吗?
Just.truncate $ 8.9
Run Code Online (Sandbox Code Playgroud)
我尝试将truncate解析为一个简单的Double - > Int:
let f :: Double -> Int; f = (\ x -> truncate x);
Run Code Online (Sandbox Code Playgroud)
......但这似乎不是问题......
Just.f $ 5.6
<interactive>:41:1:
Failed to load interface for `Just'
Use -v to see a list of the files searched for.
Run Code Online (Sandbox Code Playgroud)
非常感谢!
小智 10
当你的意思撰写的功能,它更好地写f . g比f.g.它更具可读性,你可以避免像这样的一堆问题.
如果您拥有表单Foo.bar或Foo.BarHaskell中的某些内容,则会将其解析为限定名称.这就是为什么Just.f不起作用:Just不是模块,所以Just无法加载'interface' .
为什么Just.(+3)按预期工作:(+3)是正确的部分,而不是标识符,因此点不能是限定名称的一部分.解释它的唯一方法是假设它.是运算符的中缀应用程序(.),所以它必须是Just . (+3).