sharing datatypes : best practice ?

Jan Kort kort@science.uva.nl
Fri, 11 May 2001 14:19:21 +0200


"Taesch, Luc" wrote:
> 
> do u isolate just the datatype, or a few related with, in a very small file (header like, i would say)
> or some basic accessor function with it ?
> 
> isnt it leading to massiv quantities of small files ?

Asuming you have some typed AST with many mutually recursive
datatypes, I would keep them in one big file. This should be
fine if the datatypes are simple (no "deriving" Read and Show
etc.).
For an AST you don't want accessor functions: the datatypes
are the interface. For some datatypes you want to hide
the datatype and provide a function based interface, this
should be in the same file as the datatype.
Usually there is also some kind of asumed hierarchy in
datatypes, e.g. Int < List < FiniteMap, to determine where
functions operating on multiple datatypes should be
placed, but that's the same in OO.

  Jan