[Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer...

Martijn van Steenbergen martijn at van.steenbergen.nl
Mon Apr 13 14:26:10 EDT 2009


Jason Dagit wrote:
>> removeMaybeHash x =
>>   case x of
>>   Just ref -> ref
>>   Nothing -> HashTable.new (==) (\key -> key)
> 
> When you see yourself writing a function like this, you could write it
> like this instead:
> removeMaybeHash (Just ref) = ref
> removeMaybeHash Nothing = HashTable.new (==) (\key -> key)
> 
> Hopefully you agree this 2 line version is more clear.  

Actually, I prefer the other one... (though not necessarily spread out 
over 4 lines)

I think this is more a matter of taste rather than clarity.

Martijn.


More information about the Haskell-Cafe mailing list