[Haskell-cafe] ghc should be able to deduce correct use of partial functions and not give a warning in such cases
Mark McConnell
mmcconnell17704 at yahoo.com
Tue Apr 16 14:56:55 UTC 2024
This is what I was going to say. The original poster is right, but still, null is a function. It is one level of indirection away from pattern matching.
On Tuesday, April 16, 2024 at 10:46:56 AM EDT, Henning Thielemann <lemming at henning-thielemann.de> wrote:
On Tue, 16 Apr 2024, George Colpitts wrote:
> ghc should be able to deduce correct use of partial functions and not give a warning in such cases, e.g.
> in 9.8.2
>
> if null ys then [] else [(xs,tail ys)])
>
> gets a warning
>
> warning: [GHC-63394] [-Wx-partial]
>
> but it is clear that this use of tail will never be a problem so IMHO that line of code should not get a
> warning.
>
> Does anybody know if there is a plan or enhancement request to eliminate such warnings?
I would just use good old pattern matching:
case ys of
[] -> []
_:zs -> [(xs,zs)]_______________________________________________
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/20240416/ccb78130/attachment.html>
More information about the Haskell-Cafe
mailing list