[Haskell-cafe] Re: Coding conventions for Haskell?
asviraspossible at gmail.com
Mon Sep 27 10:52:39 EDT 2010
On Mon, Sep 27, 2010 at 8:20 AM, Richard O'Keefe <ok at cs.otago.ac.nz> wrote:
> On Sep 27, 2010, at 5:31 AM, Maciej Piechotka wrote:
>> May I ask clarification about formatting (according to your convention)
>> doSomething :: (a -> a -> a) -> a -> a -> a
>> doSomething f x = f y y
>> where y = f x x
>> i.e. single line function+where
> There is a meta-rule that I use for indentation in a wide range of
> languages: where the line breaks are may depend on identifier spelling,
> but what the indentation is should not.
> In Haskell I sometimes violate that, but I usually end up regretting it.
I use the same rule. My style looks like this.
where ( FancyType (..)
data FancyType a b
= FirstConstructor a
| SecondConstructor b
f a b
| a > 0 = FisrtConstructor a
| otherwise = SecondConstructor g
where g = h b
h = id
do putStrLn hello
putStrLn . concat
, show (f 25 1)
flip mapM_ [1..100] $ \n ->
do print n
where hello = "Hello"
I allways use spaces without tabs and allways use camelCase.
More information about the Haskell-Cafe