我可以使用Traversal列表吗?以下代码:
f::[Int] -> [[Int]]
f l = [l & i .~ 1 | i<-[ix 0], (l^? i) == Just 0]
Run Code Online (Sandbox Code Playgroud)
产生错误:
• Couldn't match type ‘Const (Data.Monoid.First Int) [Int]’
with ‘Identity [Int]’
Expected type: ASetter [Int] [Int] Int Integer
Actual type: Getting (Data.Monoid.First Int) [Int] Int
• In the first argument of ‘(.~)’, namely ‘i’
In the second argument of ‘(&)’, namely ‘i .~ 1’
In the expression: l & i .~ 1
Run Code Online (Sandbox Code Playgroud)
看看这个问题,我想我需要以某种方式明确地给我一个类型,但我的每一次尝试都失败了.