[Haskell-beginners] Comfortable handling of module hierarchies

Christopher Howard christopher.howard at frigidcode.com
Sat Sep 15 03:23:45 CEST 2012

So, let's say I've got this hierarchy of modules:

  `-- Vegetable
  |    `-- Celery
  |    `-- Lettuce
  `-- Fruit
       `-- Raspberry
       `-- Apple

What I would like to be able to do is import and use modules like so:

import qualified Plant.Vegetable as V

-- call a function in module Celery


import qualified Plant as P


I tried using connecting modules, which I read about online:

code (Plant.hs):
module Plant ( module Plant.Vegetable
                     , module Plant.Fruit
import Plant.Vegetable
import Plant.Fruit

(And likewise for Plant/Vegetable.hs and Plant/Fruit.hs.) However, this
pools the functions from the sub-modules all into one name space, which
does not allow me to make the sort of function calls I described above.
Although sometime it is okay to have the functions all in one name
space, it doesn't fit the style I'm aiming for, and it can be a real
pain if multiple modules have a function of the same name (e.g., if all
fruits and veggies have a "grow" function). Is it possible to do what
I'm trying to do?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120914/81fac387/attachment.pgp>

More information about the Beginners mailing list