我是 Haskell 的新手,有人可以向我解释这段代码是如何工作的吗?
f = g (\x -> x)
g k [] = k 100
g k (x:xs) = g ((x*) . k) xs
Run Code Online (Sandbox Code Playgroud)
当我调用f [1..5]它时返回 12000。我不明白为什么。有什么作用(x*)?
PureScript中Sproxy有什么用?
在追求中,它被写成
data SProxy (sym :: Symbol)
--| A value-level proxy for a type-level symbol.
Run Code Online (Sandbox Code Playgroud)
purescipt 中的 Symbol 是什么意思?
我正在尝试用纯脚本中的 ReaderT 编写代码。但我的编译器没有正确推断类型
type Doc' = ReaderT Level (Writer (Array String)) String
line' :: String -> Doc'
line' input = do
space <- ask -- error line
lift $ tell $ [(power " " space) <> input <> "\n"]
Run Code Online (Sandbox Code Playgroud)
抛出的错误是
Could not match type
Unit
with type
String
while trying to match type t0 t1
with type ReaderT @Type Int (WriterT (Array String) Identity) String
while checking that expression (bind ask) (\space ->
(apply lift) ((...) [ ...
]
) …Run Code Online (Sandbox Code Playgroud)