[Haskell-beginners] Why do i need to take out the list for this to work

Alexander Chen alexander at chenjia.nl
Wed Jun 10 18:42:12 UTC 2020


hi,

assigment: make your own element function with the any function.

--elem with any
myElemAny :: Eq a => a -> [a] -> Bool
myElemAny a = any (== a)

--elem with any
myElemAny' :: Eq a => a -> [a] -> Bool
myElemAny' a [x]= any (== a) [x]

myElemAny' compiles but throws an error because it has a non-exhaustive pattern. Could somebody tell me why the list gives the function grieveness?

thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200610/051290ca/attachment.html>


More information about the Beginners mailing list