If I am addressing the wrong forum, then apologies in advance.
I wish to compare Haskell's type classes with CafeOBJ's module system. I realise that these constructs were originally designed to address different issues (ad-hoc polymorphism V system structuring) but they can both be used for constructing specifications. My current understanding is as follows:
In CafeOBJ the module is the basic unit for structuring both specifications and programs.
A module can denote either a theory (loose denotation) in some logic or denote the initial algebra (tight denotation) in some logic(s) (e.g. equational logic or preorder logic). See: http://crab.rutgers.edu/~pjohann/tlca07-rev.pdf
My interpretation is that a loose module in CafeOBJ roughly corresponds to a Haskell class, while a tight module corresponds to a Haskell instance. CafeOBJ modules can be parameterised by other modules whereas Haskell class/instances are parameterised by types. CafeOBJ modules can also import other modules. This importation includes facilities to rename elements (sorts and functions). Importation also allows the user to construct logically valid mappings between elements in the imported module and the importing module. Haskell type classes do not import in this sense, their only structuring mechanisms are parameterisation and inheritance. Importing in Haskell is handled by Haskell's own module system which operates above the type class system.
Question 1:
Is my rough mapping from CafeOBJ modules to Haskell type classes reasonable? Obviously, I am not talking at a very detailed or formal level.
Question 2:
Notwithstanding my current understanding of Haskell set out above, is there any way of 'importing' type classes into type classes or instances into instances.
Question 3:
Lutz Schroder talks about type classes being a 'pre-institution' for polymorphism.
My understanding of his paper is that type classes do not support 'model expansion', because expanded models may have more types. Is this due to the lack of an import facility in Haskell's type classes?
See: http://www.informatik.uni-bremen.de/~lschrode/papers/Summary.ps
Question 4: What are the strengths, weakness of Haskell type classes and CafeOBJ's modules for specifying systems? (as opposed to programming)
Regards,
Patrick Browne
Recent comments
22 weeks 2 days ago
22 weeks 3 days ago
22 weeks 3 days ago
44 weeks 4 days ago
48 weeks 6 days ago
50 weeks 3 days ago
50 weeks 3 days ago
1 year 1 week ago
1 year 5 weeks ago
1 year 5 weeks ago