[Haskell-cafe] incomplete-uni-patterns

David Feuer david.feuer at gmail.com
Thu Jan 26 08:36:00 UTC 2023


A lazy pattern match isn't opting into partiality. Lazy patterns are often
things like tuples.

On Thu, Jan 26, 2023, 12:49 AM Jeff Clites via Haskell-Cafe <
haskell-cafe at haskell.org> wrote:

> That was my thinking with using an explicit lazy pattern match indication:
>
>     let ~(Just a) = …
>
> It seems to me that this shouldn’t warn (though apparently it does), since
> it’s overly opting in to a non-exhaustive match.
>
> Jeff
>
> On Jan 25, 2023, at 9:08 PM, David Feuer <david.feuer at gmail.com> wrote:
>
> 
> It seems to me that instead of working around this, we should add a pragma
> to suppress the warning at the pattern site. Maybe something like
>
> let
>   {-# PARTIAL_MATCH #-}
>   Just a = blah blah
>
> That way GHC can see that you noticed the partial match and that you're
> okay with it.
>
> On Wed, Jan 25, 2023, 7:06 PM Kazu Yamamoto (山本和彦) via Haskell-Cafe <
> haskell-cafe at haskell.org> wrote:
>
>> Hello,
>>
>> The recent GHC added incomplete-uni-patterns to the -Wall option.
>> So, we have a waning with the following code:
>>
>>     let [addr,port] = args
>>
>> To avoid this, I changed the code to:
>>
>>     let addr = head args
>>         port = head $ tail args
>>
>> In my opinion, this seems Lisp rather than Haskell.
>>
>> Also, I need to avoid:
>>
>>     let Just val = mval
>>
>> Rahter, I use:
>>
>>     let val = fromJust mval
>>
>> This is annoying to me.
>>
>> How do you get along with incomplete-uni-patterns?
>> I would like to know the best current practice.
>>
>> --Kazu
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> To (un)subscribe, modify options or view archives go to:
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>> Only members subscribed via the mailman list are allowed to post.
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20230126/7ac7ae82/attachment.html>


More information about the Haskell-Cafe mailing list