[Haskell-cafe] ghc should be able to deduce correct use of partial functions and not give a warning in such cases

Henning Thielemann lemming at henning-thielemann.de
Sat Apr 20 12:35:40 UTC 2024


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.


More information about the Haskell-Cafe mailing list