[Haskell-cafe] Re: haskell programming guidelines

Christian Maeder maeder at tzi.de
Wed Feb 22 07:14:41 EST 2006


Donald Bruce Stewart wrote:
> Perhas you'd like to put up a Style page on thew new Haskell wiki,
> perhaps under the Idioms category?

I cannot promise it, but I'll try. If someone else is willing to do it, 
I would support this.

Rob Dockins wrote:
>> I understood that part of the guidelines as a pleading for Maybe.
> 
> Humm.  Well clearly I read it the opposite way.  I suppose that means  that whatever technique is being recommended should be put forth with  more clarity ;-)

done (use Maybe or another Monad)

Andrew Bromage wrote:
> So, for example, f (g (h x)) can be expressed well as:
> 
>     f . g $ h x          -- only use if you need to distinguish h
>     f . g . h $ x        -- better

I see this differently. Expressions may be succinct! I find "$" and "." 
similar enough for non-obfuscation. But I collect cases where "$" does 
not work (i.e. for the kind #). Bad would be cases where "$" works 
differently than (reasonably) expected.

John Meacham wrote:
> f x = ... y ... where
>         Just y = Map.lookup x theMap
> 
> now if the lookup fails you automatically get an error message pointing
> to the exact line number of the failure. or if the failure message of
> the routine is more important than the source location you can do
> 
> f x = ... y ... where
>         Identity y = Map.lookup x theMap

These are potential runtime errors, that may be not so obvious to see in 
the source (ie. for user defined types) and even the compiler (ghc) does 
not emit a warning.

Thanks for all your comments
Christian


More information about the Haskell-Cafe mailing list