My function paralellenCheck throws an exception everytime I call it complaining about Non-exhaustive patterns
paralellenCheck is defined as follows:
paralellenCheck :: (Eq a, Num a ) => [a] -> [a] -> Bool
paralellenCheck [] [] = True
paralellenCheck [_] [] = True
paralellenCheck [] [_] = True
paralellenCheck (x:xs) (y:ys)
| intervall `elem` [0,5,7,12] = False
| not $ paralellenCheck (x:xs) ys = False
| not $ paralellenCheck xs (y:ys) = False
| otherwise = True
where intervall = abs (x - y)
running the function in GHCI with -Wall applied just returns
<interactive>:10:1:
Warning: Defaulting the following constraint(s) to type `Integer'
(Eq a0)
arising from a use of `paralellenCheck' at <interactive>:10:1-15
(Num a0)
arising from a use of `paralellenCheck' at <interactive>:10:1-15
In the expression: paralellenCheck [] [2, 3, 4, 5]
In an equation for `it': it = paralellenCheck [] [2, 3, 4, ....]
<interactive>:10:1:
Warning: Defaulting the following constraint(s) to type `Integer'
(Eq a0)
arising from a use of `paralellenCheck' at <interactive>:10:1-15
(Num a0)
arising from a use of `paralellenCheck' at <interactive>:10:1-15
In the expression: paralellenCheck [] [2, 3, 4, 5]
In an equation for `it': it = paralellenCheck [] [2, 3, 4, ....]
*** Exception: haskelltest.hs:(6,1)-(14,31): Non-exhaustive patterns in function paralellenCheck
I am rather new to haskell and rather confused. I thought the pattern-matching with [_] [] and [] [_] should resolve this issue.
[_]with just_. Also, you might want to supply your definitions for(x:xs) (y:ys)first, and then supply a_ _ = Truepattern afterwards. - C. Quilley_ _- user3763118