[Haskell-cafe] Best idiom for avoiding Defaulting warnings with ghc -Wall -Werror ??

Dave Bayer bayer at cpw.math.columbia.edu
Fri Jun 22 20:39:10 EDT 2007

On Jun 22, 2007, at 4:37 PM, David Roundy wrote:

> You get strongly-typed code whether or not you enable warnings.

In my opinion it's delusional to think one is using strong typing if  
one doesn't enable warnings. All the puffing about the advantages of  
strong typing look pretty silly if code hangs up on an incomplete  
pattern. Let's remember that the other side of this debate is rather  
eloquent, be it Paul Graham or a Ruby enthusiast. People who don't  
worry so much about types believe that they get things done. Is using  
a strongly typed language like buying a hybrid car, it costs too much  
but you're helping with "maybe someday...?"

I refuse to drink the Kool-Aid and recite precisely what I'm told a  
type is in June, 2007; I'm hoping that types will evolve by the time  
I die. For types to evolves, we need to step back a few feet and  
think more loosely what a type really is.

If someone writes working code with incomplete patterns, they're  
effectively using a dependent type without being able to say so in  
Haskell. They're using a specialization of the type they claim to be  
using, in which the missing patterns are never needed. Filling in with

	_  -> error "I'm sweeping this under the rug so it's no longer the  
type system's problem"

just highlights the inadequacy of the type system. The code hangs  
either way, if the belief that this case doesn't happen is wrong. I'm  
more of a "Will the code hang or not?" kind of guy than "Will I be  
kicked out of the tree house if I use the wrong words for things?"  
kind of guy. The missing pattern that shouldn't happen is abstractly  
a type issue, whether we can get the compiler to lay off or not.

Similarly, the whole defaulting debate is good form/bad form  
considerations for how best to use types to automatically write code  
for us.

It all comes back to what I said before, types are compile-time  
proxies for run-time values. I'm nudging at compile-time, therefore  
I'm messing with types, not values.

If I go away and write in Lisp or Ruby, then return to Haskell with  
"ghc -Wall -Werror", it is glaringly obvious to me that the nudging I  
have to do to get things to work with warnings on has to do with  
types. I truly don't mind the nudging, it is very educational, but  
let's call a spade a spade?

More information about the Haskell-Cafe mailing list