public/private module sections (was: Haskell-prime Digest, Vol 2, Issue 58)

Claus Reinke claus.reinke at talk21.com
Fri Feb 24 10:55:51 EST 2006


> so:

not quite (though I believe that would be close to Simon M's idea).

in my modification, both map and length would move completely
into the export section, length# would stay in the local section.
both sections would just be module <body>s., containing full
definitions, declarations, imports. to export anything, move it
to the export section, to hide anything, move it to the local 
section (and in case that wasn't clear, these would be two 
sections of the same module <body>, only distinguished by
whether or not their contents are exported).

cheers,
claus
 
> -- |iterate function over list
> map :: (a->b) -> [a] -> [b]
> 
> -- |find length of list
> length :: [a] -> Int
> 
> private:
> 
> map f (x:xs) = f x : map f xs
> map f []     = []
> 
> length xs = length# xs 0#
> 
> length# (x:xs) n# = length# xs (n# +# 1)
> length# []     n# = n#
> 
> 
> and in order to see map's type or comment when i implement it, i
> should see to other part of file. i personally prefer to have
> public/private modifiers on each function and gather interface
> documentation by tools like haddock
> 
> 
> -- 
> Best regards,
> Bulat                            mailto:Bulat.Ziganshin at gmail.com
>


More information about the Haskell-prime mailing list