organize an haskell package between several files
again a total ne开发者_C百科wbie question from me about Haskell, and Leskah.
(First, a subjective compliment for Haskell lovers: at each come back for a learning session of Haskell I like it more and more. I hope this will go on for long :-). Latest pleasure has been Leskah's sugar for auto transforming symbols into math. It makes code looks really nice. But well that's not the point... )
I wanted to organize my learner package into several files. But I didn't succeed in adding a second file e.g. Second.hs, containing other definitions, to my current package build unit. I have added it in Leskah/Edit Package/Extra Files. But this doesnt seem to do the job. More over I feel as it it was a little bit akward to add each of any new file this way ( thru Leskah/Edit Package/Extra Files ).
Anyway as a result all that is built is still only the content my Main.hs. I am surely missing some point ?!
Another question is, in C++, I heavily use namespace
so as to sort my object definitions by subject/goal. What is the equivalent of namespace in Haskell ? A module ? A package ?
Regarding to leksah: you can add new module through the Browser panel. Just right click and select "Add module" from the context menu (Note: enter module name, but not a file name in the dialog). Adding modules from Package Editor is designed just to add existent module to the cabal file. (If you don't know what "cabal" means, then it is a good time to google it :) )
Regarding to namespace. I think the nearest equivalent is module. You can just import module to add definitions to current context. Alternatively you can import module qualified, in that case you will have to qualify definitions from the module. Also you can "alias" module name when importing it.
import Module1
import qualified Modile2
import Module3 as M3
import qualified Modile4 as M4
Package is equivalent to compiled library in C/C++.
精彩评论