我可以使用遍历列表吗?以下是代码:
f::[Int] -> [[Int]]
f l = [l & i .~ 1 | i<-[ix 0], (l^? i) == Just 0]
产生一个错误:
• 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
看了这个问题,我认为我需要明确地给i指定一个类型,但是我的每一次尝试都失败了。