Haskell
Haskell 是一种函数式编程语言。
笔记
printf debugging
import Debug.Trace
dbg :: Show a => String -> a -> a
dbg msg x = trace (msg ++ " " ++ show x) x
使用方法:把变量 x
换成 (dbg "x =" x)
。
let
与 where
let
是一个表达式,而 where
不是。where
用于给多个 guard 创建 binding,如下:
f x y
| y > z = ...
| y == z = ...
| y < z = ...
where
z = x * x
Hlint
Ignore warnings
在 .hlint.yaml
中写:
- ignore: {name: Eta reduce}
另见
外部链接
参考资料
- ↑ https://stackoverflow.com/q/4362328/10974106
- ↑ A Gentle Introduction to Haskell 4.5 Lexical Scoping and Nested Forms
- ↑ https://neilmitchell.blogspot.com/2019/01/ignoring-hlint.html