[Haskell-beginners] Non-exhaustive patterns in function error

Francesco Ariis fa-ml at ariis.it
Thu Feb 25 23:45:41 UTC 2021


Il 25 febbraio 2021 alle 17:23 Galaxy Being ha scritto:
> I have this
> 
> intersect1 :: ([a],[a]) -> [a]
> intersect1 (s,[])              = []
> interesct1 (s,t:ts) | elem t s = t : intersect1 (s,ts)
>                     | otherwise = intersect1 (s,ts)
> 
> and when I try this
> 
> intersect1 ([1,2],[1,2,3])
> 
> I get the error
> 
>  Non-exhaustive patterns in function intersect1
> 
> Not sure what's wrong with this.

Pattern (_,[]) is not matched!


More information about the Beginners mailing list