Proposal: improve the Data.Tree API

Milan Straka fox at ucw.cz
Fri Mar 14 08:49:40 UTC 2014


> -----Original message-----
> From: Henning Thielemann <schlepptop at henning-thielemann.de>
> Sent: 14 Mar 2014, 09:39
>
> <snip>
>
> >The idea was to provide two modules, Data.Tree and Data.Tree.Forest. The
> >methods for Forest would be in Data.Tree.Forest. To use the modules, the
> >users would write
> >   import qualified Data.Tree as Tree
> >   import qualified Data.Tree.Forest as Forest
> >and then use the methods as
> >   Tree.lookupTree
> >   Tree.filter
> >and
> >   Forest.filter
> 
> I find this naming scheme attractive. In order to break module
> cycles I usually define private modules. E.g.
> 
> Data.Tree.Private exports Tree, but the module is hidden
> Data.Tree.Forest imports Tree, exports Forest, module is exposed
> Data.Tree imports Tree and Forest, exports Tree, module is exposed

You are right, no dependency cycle here.

Nevertheless, we probably have to export both Tree a and Forest a from
Data.Tree, as the Tree datatype uses Forest. Forest is actually only
  type Forest a = [Tree a]
so it is not such a big issue :)

We should probably reexport Tree a and Forest a from Data.Tree.Forest
too, so that users can use only Data.Tree.Forest module without
Data.Tree.

Cheers,
Milan


More information about the Libraries mailing list