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

Brody Berg brodyberg at gmail.com
Fri Feb 26 03:51:41 UTC 2021


Don’t worry about it. We’ve all been there.

On Thu, Feb 25, 2021 at 18:01 Galaxy Being <borgauf at gmail.com> wrote:

> How embarrassing...
>
> intersect1 :: (Eq a) => ([a],[a]) -> [a]
>
>
> On Thu, Feb 25, 2021 at 5:53 PM Bob Ippolito <bob at redivi.com> wrote:
>
>> It's the typo. Note that you'll also need an Eq a typeclass constraint
>> for this type signature to be correct (which is the next error you'd get)
>>
>> -- underscores for emphasis
>> inter_se_ct1
>> inter_es_ct1
>>
>>
>> On Thu, Feb 25, 2021 at 3:24 PM Galaxy Being <borgauf at gmail.com> wrote:
>>
>>> 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.
>>>
>>> LB
>>>
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> Beginners at haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210225/7cfab5d0/attachment-0001.html>


More information about the Beginners mailing list