What does import Some.Module as Import mean in Yesod?

The scaffolded site in Yesod creates an Import.hs file that contains the following.

 module Import ( module Import ) where import Prelude as Import import Yesod as Import -- ... 

What is this template for? I understand that it exports all of the modules imported into the Import.hs package, but not just module Import where to do the same? What is the meaning of the nested keyword module inside module Import (module Import) where ... ?

+6
source share
1 answer

A Haskell language report describes module export as:

The form “module M” refers to the set of all objects that are in scope, with both the unqualified name “e” and the qualified name “Me”. This set may be empty.

§5.2 Export of lists

The export list identifies the objects that will be exported by the module declaration. A module implementation can only export the object that it declares, or imports it from some other module. If the export list is omitted, all values, types, and classes defined in the module are exported, but not imported.

Entities in the export list can be named as follows:

  • ...

  • The “module M” form calls the set of all objects that are in scope with both the unqualified name “e” and the qualified name “Me”. This set may be empty.

This means that the semantics are:

 module Import ( module Import ) where import Prelude as Import import Yesod as Import -- ... 

- take everything that is contained in the Prelude and Yesod modules, and export it.

Instead, you suggest:

 module Import where 

will not export what is imported by Prelude and Yesod as above:

If the export list is omitted, all values, types and classes defined in the module are exported , but not imported .

+9
source

Source: https://habr.com/ru/post/970594/


All Articles