[Haskell-cafe] Avoiding name collisions by using value spaces instead of modules

Tomasz Zielonka tomasz.zielonka at gmail.com
Mon Jan 16 06:51:13 EST 2006

[A bit late reply - I've just returned from vacation]

On Sun, Jan 08, 2006 at 05:47:19PM -0000, Brian Hulley wrote:
> All I'm proposing is that the compiler should do all this painful work for 
> you, so that you don't need to bother creating a different file that then 
> needs two import directives to achieve the effect I want. Is there any case 
> where you would *not* want a type to be declared in its own module?

I can think of such cases - for example consider a set of mutually
recursive datatypes used to represent abstract syntax trees in some
language. Of course, I imagine that "your modules" could be introduced
in such a way that would still allow recursion, but it's simply more
natural for me to place all those declarations in one module named
Syntax or AST.

> It is quite simple to create a new layout rule. My idea with this is that 
> all lines should start with zero or more tab characters (non-tab leading 
> whitespace is disallowed),

All lines start with at least zero tab characters, trivially.

> and all layout blocks should start on a new line.

That's a good coding practice (yes, you can write like this in Haskell
already), making your code more change-friendly, which is especially
important when you use some version control tool. It would be nice if
this could be enforced by the compiler, at least as some kind of a
warning. I encourage you to add such option to some Haskell compiler, or
a coding policy checking tool :-)

> Moreover, it is possible to completely dump the ugly let..in 
> construct, and make "=" one of the tokens that can start a new layout 
> block, so instead of:
>    f x = let a = x+1
>                 b = x + 2
>            in a + b

How about

    f x =
            a = x + 1
            b = x + 2
            a + b

Anyway, I would use "where" here.

> one would simply write:
>    f x =
>            a = x+1
>            b = x+2
>            a + b

I don't like it. It's shorter, but less readable too. You could simply

   f x =
           a + b
           a = x+1
           b = x+2

which is not that much longer, but much more readable.

Best regards

I am searching for programmers who are good at least in
(Haskell || ML) && (Linux || FreeBSD || math)
for work in Warsaw, Poland

More information about the Haskell-Cafe mailing list