[Haskell-cafe] incomplete-uni-patterns

Mark McConnell mmcconnell17704 at yahoo.com
Thu Jan 26 02:24:28 UTC 2023


 I feel I should raise the naive question, what if args is wrong?
[addr,50,50]  when a user mistyped port 5050 as 50 50
[addr]   when a user was "sure" somebody else's code would insert 5050 as the default
What would you like your code to do in those two cases?
I have been using Haskell seriously for only about two years, so I am still idealistic about it.  On the other hand, I worked in the software industry for about ten years, and back then my boss would have chewed me out if my Java code had crashed on the input of 50 50.    On Wednesday, January 25, 2023 at 07:06:30 PM EST, 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.  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20230126/11c1f93c/attachment.html>


More information about the Haskell-Cafe mailing list