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

Bulat Ziganshin bulat.ziganshin at gmail.com
Fri Feb 24 11:13:10 EST 2006


Hello Claus,

Friday, February 24, 2006, 6:55:51 PM, you wrote:

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

CR> in my modification, both map and length would move completely
CR> into the export section

WHY? it's not the interface. implementation of exported functions is
of no interest for module users like the implementations of any other
functions. i tried to emphasize this moment - in any case we should
either duplicate part of code or have the definitions splitted in the
very unpleasant manner. i prefer instead to not have "interface"
section at all and generate it automatically by haddock

>> -- |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