Module name
一個模塊名是一系列用點號分隔的標識符。
這些標識符首字母都是大寫,點號兩邊沒有空格。
A module name is a sequence of one or more identifiers beginning with capital letters, separated by dots, with no intervening spaces.——P62
一個qualified name由模塊名.unqualifed name
構成。
Import declarations
(1)import A(f)
:導入值(value),字段名(field name),類方法(class method),其中A
是被導入的模塊名
(2)import A(T)
:只導入類型構造器(type constructor)/ 只導入類型類(class)
(3)import A(T(f,g))
:導入類型構造器和給定的值構造器(data constructor)和字段名(field name)/ 只導入類型類和給定的類方法(class method)
(4)import A(T(..))
:導入類型構造器和它所有的值構造器,和所有的字段名 / 導入類型類和它所有的類方法
(5)import A()
:不導入模塊A
中的任何entity
(6)import A
:導入模塊A
中所有的entity
(7)import qualifed A
:導入A中的qualified name(例:只導入A.f
)
(8)import qualifed A as B
:導入A中的entity,并修改qualified name的模塊名。(例:B.f
)
注:
(1)默認所有導出方式,都導入instance declarations
(2)以上T
不可以是值構造器,值構造器只能放在T
的括號中導入
(3)值構造器可以直接寫在hiding
中,此時屏蔽同名的值構造器,類型構造器以及類型類
(4)如果不使用qualified導入方式,則qualifed name和unqualified name都被導入,如果使用了qualified導入方式,則只導入qualifed name。
If the import declaration used the qualified keyword, only the qualified name of the entity is brought into scope. If the qualified keyword is omitted, then both the qualified and unqualified name of the entity is brought into scope.——P65
Export list
(1)module A(f) where
:同import declarations
(2)module A(T) where
:同import declarations
(3)module A(T(f,g)) where
:同import declarations
(4)module A(T(..)) where
:同import declarations
(5)module A(module B) where
:導出模塊B
中所有的entity
(6)module A(module A) where
:導出本模塊中所有的entity
(7)module A() where
:不導出任何entity
(8)module A where
:導出所有的entity
注:
(1)默認所有導出方式,都導出instance declarations
(2)以上T
不可以是值構造器,值構造器只能放在T
的括號中導出
(3)module A where
只能導出模塊中所有的值,類型和類型類,但是不能導出模塊導入的名字。
A module implementation may only export an entity that it declares, or that it imports from some other module. If the export list is omitted, all values, types and classes defined in the module are exported, but not those that are imported.——P63