[Haskell-cafe] Re: Merging modules (again)
pat browne
Patrick.Browne at comp.dit.ie
Sun Oct 18 13:11:13 EDT 2009
Hi,
I have tried qualified imports, synonyms and newtypes but still I could
not implement the merging task (previously posted). This is probably
because I have little knowledge of Haskell *or* the task is not really
suited to Haskell (more of a specification task than a programming task).
My main questions are;
Can the merging task be achieved using the Haskell module system?
I also posted a question on how this task could be done using type
classes. I would ask the same question with respect to type classes.
Regards,
Pat
pat browne wrote:
> Hi,
> I want to establish the strengths and weakness of the Haskell module
> system for the ontology merging task (I know it was not designed for
> this!). I wish to make a new module (MERGEDONTOLOGY) from three input
> modules one of which is common to the other two.
> The desired merge should contain the following data types:
> Woman FinancialBank HumanBeing RiverBank
> Which are all identifiable without any qualifying module names.
>
> Below is the detailed requirement and my first attempt at this task in
> Haskell. I would be grateful for any information on how to merge these
> modules giving a set of unique unqualified types (i.e. without reference
> to their originating modules).
>
> Regards,
> Pat
>
>
>
>
> ========================
> Informal Specification
> ========================
>
> The diagram and text below explain the requirement
>
> MERGEDONTOLOGY
> { Woman, RiverBank, FinancialBank, HumanBeing}
> /\ /\
> / \
> / \
> / \
> / \
> / \
> / \
>
> ONTOLOGY1 ONTOLOGY2
> {Woman, Bank, Person} {Woman, Bank, Human}
> /\ /\
> \ /
> \ /
> \ /
> \ /
> \ /
> \ /
> \ /
> {Woman , Person}
> COMMMON
>
> This example includes both synonyms and homonyms.
> 1)The Woman sort (or data type) should be the same in all modules, there
> is only one Woman sort and it is named as such in each module. Hence
> there should be only one MERGEDONTOLOGY.Woman.
>
> 2)There is only one sort MERGEDONTOLOGY.HumanBeing, but there are 3
> synonyms for it called ONTOLOGY2.Human, ONTOLOGY1.Person, and
> COMMON.Person. The last sentence considers ONTOLOGY1.Person and
> COMMON.Person as synonyms; they have different qualifiers but the
> intention is that they represnt the same thing. Hence should be mapped
> to same MERGEDONTOLOGY.HumanBeing. To do this (in Maude) COMMON.Person
> was renamed to ONTOLOGY2.Human which in turn was renamed to
> MERGEDONTOLOGY.HumanBeing.
>
> 3)The homonyms are ONTOLOGY1.Bank and ONTOLOGY2.Bank should become
> distinct sorts MERGEDONTOLOGY.RiverBank and
> MERGEDONTOLOGY.FinancialBank in the final ontology at the top of the
> diagram.
>
>
> ================================================
> My first attemt at merging using Haskell modules
> =================================================
> module COMMON where
> data Woman = WomanC
> data Person = PersonC
>
>
>
> module ONTOLOGY1 where
> import COMMON
> data Bank = BankC
>
>
> module ONTOLOGY2 where
> import COMMON
> data Bank = BankC
>
>
>
> module MERGEDONTOLOGY where
> import ONTOLOGY1
> import ONTOLOGY2
>
> If I use qualified names all the constructors are interpreted correctly
> MERGEDONTOLOGY> :t COMMON.WomanC
> COMMON.WomanC :: COMMON.Woman
> MERGEDONTOLOGY> :t COMMON.PersonC
> COMMON.PersonC :: COMMON.Person
> MERGEDONTOLOGY> :t ONTOLOGY2.BankC
> ONTOLOGY2.BankC :: ONTOLOGY2.Bank
> MERGEDONTOLOGY> :t ONTOLOGY1.BankC
> ONTOLOGY1.BankC :: ONTOLOGY1.Bank
> MERGEDONTOLOGY> :t COMMON.Woman
>
> However, I wish that these types and constructors be fully defined in
> the context of the MERGEDONTOLOGY. I have tried type synonyms and newtypes.
> type RiverBank = ONTOLOGY1.Bank
> type FinancialBank = ONTOLOGY2.Bank
> newtype RiverBank = BankC Int
> I have not explored import modes or qualified imports.
>
>
>
More information about the Haskell-Cafe
mailing list