Re: ghc should be able to deduce correct use of partial functions and not give a warning in such cases

Henning Thielemann <[email protected]>
Newsgroups gmane.comp.lang.haskell.cafe
Message-ID <[email protected]>
On Sat, 20 Apr 2024, George Colpitts wrote:

> Thanks for everybody's replies
> 
> To give more context the original code from Ch. 12 of Bird's Thinking Functionally with Haskell was:
>
>       let (xs, ys) = break (== ch) str in
> 
>          if null ys then [] else [(xs, tail ys)])
> 
> I replaced it with 
>
>       let (xs, ys@(_ : t)) = break (== ch) str in
> 
>          if null ys then [] else [(xs, t)])


This won't work. ys@(_ : t) only matches on non-empty lists. It will also 
give you warnings, but this warning may not be contained in -Wall 
depending on the GHC version.

_______________________________________________
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.