[Haskell-cafe] a sort of chunk
ietf-dane at dukhovni.org
Mon Jan 20 23:47:47 UTC 2020
On Mon, Jan 20, 2020 at 05:39:16AM -0500, Viktor Dukhovni wrote:
> > > src/Hkl/Projects/Sixs.hs:67:5-35: warning: [-Wincomplete-uni-patterns]
> > > Pattern match(es) are non-exhaustive
> > > In a pattern binding: Patterns not matched: 
> > > |
> > > 67 | cons1 !x ~(c:cs) = (x : c) : cs
> > > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > If this is something which can not be reach, is it possible to explain to ghc how to avoid these warning ?
> However, with "-Wincomplete-uni-patterns" I still get this one, but the
> irrefutable binding is there for a reason, stricness in the second
> argument has undesirable performance implications, we know that the list
> won't be empty. So perhaps compile this code in a module that does not
> have that warning turned on.
Actually, the warning can be eliminated by writing:
cons1 x cs = (x : head cs) : tail cs
which just as "unsafe" (we know that `cs` won't be empty, but the
compiler does not), but use of the partial functions 'head' and 'tail'
does not elicit a warning. The `!x` is also redundant, we've already
evaluated the weight of `x`'.
More information about the Haskell-Cafe