I have the following code in haskell and I get
- Couldn't match type [Int] with `Bool'
- Couldn't match type
[[a0]] -> [a0]' with
[Int]' Expected type: [Int] -> [Int] Actual type: [Int] -> [[a0]] -> [a0]
Code:
findlist:: [[Int]] -> [Int]
findlist (l1, l2, l3, l4, l5) = do 1)
let n = length l1
e1 <- [1..n]
e2 <- [1..n]
e3 <- [1..n]
e4 <- [1..n]
e5 <- [1..n]
let list1 = pick_list $ myperms e1 l1 --here
list2 = pick_list $ myperms e2 l2 --here
list3 = pick_list $ myperms e3 l3 --here
list4 = pick_list $ myperms e4 l4 --here
list5 = pick_list $ myperms e5 l5 --here
guard $ all (== list1) $ [list2, list3, list4, list5]
guard $ e1 `notElem` [e2, e3, e4, e5]
guard $ e2 `notElem` [e3, e4, e5]
guard $ e3 `notElem` [e4, e5]
guard $ e4 `notElem` [e5]
return concat list1 2)
Type signatures:
pick_list:: [[Int]] -> [Int]
myperms:: Int -> [Int] -> [[Int]]
What's wrong with it and how can I realize when I'm gonna get such errors? Thanks in advance.
myperms :: Int -> [Int] -> [[Int]]
;myperms = undefined
andpick_list :: [[Int]] -> [Int]
;pick_list = undefined
. Additionally, I doubt you tried to compile this exact code becausefindlist
takes a 5-tuple, not a list, but you clearly have given it a type signature that says it takes a list. That's the only compile error I get with this code. – bheklilr