Basic problem in Haskell language design?

Hi, Today I found the following problem when writing a simple function:
-- Whole info from a word8 list to moves movesFromWord8s :: [Word8] -> [Move] movesFromWord8s (f:t:ws) = (f, t) : movesFromWord8s ws moverFromWord8s _ = []
Here I made a small typo in the second equation, writing "mover..." instead of "moves..." for the name of the declared function. Of course this is an error, because I have non-exhaustive patterns in the function movesFromWord8s. But the compiler (here GHC 6.8.2 on WinXP) has in principle no chance to detect this mistake, I saw it only in QuickCheck (aka at run-time). I think this is a basic problem with the language design. In small programs it's not so bad, but in large ones this could be. What do you think about it? Are there possible solutions or workarounds? Nicu Ionita

"Nicu Ionita"
Hi,
Today I found the following problem when writing a simple function:
-- Whole info from a word8 list to moves movesFromWord8s :: [Word8] -> [Move] movesFromWord8s (f:t:ws) = (f, t) : movesFromWord8s ws moverFromWord8s _ = []
Here I made a small typo in the second equation, writing "mover..." instead of "moves..." for the name of the declared function. Of course this is an error, because I have non-exhaustive patterns in the function movesFromWord8s. But the compiler (here GHC 6.8.2 on WinXP) has in principle no chance to detect this mistake, I saw it only in QuickCheck (aka at run-time).
I think this is a basic problem with the language design. In small programs it's not so bad, but in large ones this could be. What do you think about it? Are there possible solutions or workarounds?
-Wall? The number of -W options enabled should scale (at least) linearly with code size. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.

On Mon, Mar 2, 2009 at 12:35 AM, Achim Schneider
-Wall? The number of -W options enabled should scale (at least) linearly with code size.
To make this a little more clear: You should probably be using the -Wall compiler option, which will produce a message for code constructs that the compiler finds suspicious. In your case you should see three relevant warnings: 1. "moverFromWord8s" is defined but not used 2. "moverFromWord8s" has no explicit type signature 3. "movesFromWord8s" has a non-exhaustive pattern match Stuart

Ok, thanks, compiling from Eclipse I totally forgot to check the compiler flags. Nicu Ionita
-----Ursprüngliche Nachricht----- Von: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] Im Auftrag von Stuart Cook Gesendet: Sonntag, 1. März 2009 14:45 An: haskell-cafe@haskell.org Betreff: Re: [Haskell-cafe] Re: Basic problem in Haskell language design?
On Mon, Mar 2, 2009 at 12:35 AM, Achim Schneider
wrote: -Wall? The number of -W options enabled should scale (at least) linearly with code size.
To make this a little more clear:
You should probably be using the -Wall compiler option, which will produce a message for code constructs that the compiler finds suspicious.
In your case you should see three relevant warnings:
1. "moverFromWord8s" is defined but not used 2. "moverFromWord8s" has no explicit type signature 3. "movesFromWord8s" has a non-exhaustive pattern match
Stuart _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Stuart Cook wrote:
On Mon, Mar 2, 2009 at 12:35 AM, Achim Schneider
wrote: -Wall? The number of -W options enabled should scale (at least) linearly with code size.
To make this a little more clear:
You should probably be using the -Wall compiler option, which will produce a message for code constructs that the compiler finds suspicious.
In your case you should see three relevant warnings:
1. "moverFromWord8s" is defined but not used 2. "moverFromWord8s" has no explicit type signature 3. "movesFromWord8s" has a non-exhaustive pattern match
And that warning #3 is the one that you really should care about. It'll save you. -- John
Stuart _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

You could turn on -Wall to get a whole bunch of such warnings. Am 01.03.2009 um 14:26 schrieb Nicu Ionita:
Hi,
Today I found the following problem when writing a simple function:
-- Whole info from a word8 list to moves movesFromWord8s :: [Word8] -> [Move] movesFromWord8s (f:t:ws) = (f, t) : movesFromWord8s ws moverFromWord8s _ = []
Here I made a small typo in the second equation, writing "mover..." instead of "moves..." for the name of the declared function. Of course this is an error, because I have non-exhaustive patterns in the function movesFromWord8s. But the compiler (here GHC 6.8.2 on WinXP) has in principle no chance to detect this mistake, I saw it only in QuickCheck (aka at run-time).
I think this is a basic problem with the language design. In small programs it's not so bad, but in large ones this could be. What do you think about it? Are there possible solutions or workarounds?
Nicu Ionita
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (6)
-
Achim Schneider
-
Adrian Neumann
-
Daniel Fischer
-
John Goerzen
-
Nicu Ionita
-
Stuart Cook