14.11.2012 Views

Curry: An Integrated Functional Logic Language

Curry: An Integrated Functional Logic Language

Curry: An Integrated Functional Logic Language

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

import stack<br />

imports all entities exported by the module stack, whereas the declaration<br />

import family(father, grandfather)<br />

imports only the entities father and grandfather from the module family, provided that they<br />

are exported by family. Similarly to export declarations, a datatype name t in an import list<br />

imports only the datatype without its constructors whereas the form t(..) imports the datatype<br />

together with all its constructors (provided that they are also exported).<br />

The names of all imported entities are accessible in the current module, i.e., they are equivalent<br />

to top-level declarations, provided that their names are not in conflict with other names. For<br />

instance, if a function f is imported from module m but the current module contains a top-level<br />

declaration for f (which is thus directly accessible in the current module), the imported function is<br />

not accessible (without qualification). Similarly, if two identical names are imported from different<br />

modules and denote different entities, none of these entities is accessible (without qualification). It<br />

is possible to refer to such imported but not directly accessible names by prefixing them with the<br />

module identifier (qualification). For instance, consider the module m1 defined by<br />

module m1 where<br />

f :: Int -> Int<br />

...<br />

and the module m2 defined by<br />

module m2 where<br />

f :: Int -> Int<br />

...<br />

together with the main module<br />

module main where<br />

import m1<br />

import m2<br />

...<br />

Then the names of the imported functions f are not directly accessible in the main module but one<br />

can refer to the corresponding imported entities by the qualified identifiers m1.f or m2.f.<br />

<strong>An</strong>other method to resolve name conflicts between imported entities is the qualification of an<br />

imported module. If we change the main module to<br />

module main where<br />

import qualified m1<br />

import m2<br />

...<br />

then the name f refers to the entity m2.f since all entities imported from m1 are only accessible by<br />

qualification like m1.f.<br />

A further method to avoid name conflicts is the hiding of imported entities. Consider the<br />

following definition:<br />

25

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!