I have two .hs files: one contains a new type declaration, and the other uses it.
first.hs:
module first () where
type S = SetType
data SetType = S[Integer]
second.hs:
module second () where
import first
When I run second.hs, both modules first, second are loaded just fine.
But, when I write :type S on Haskell platform, the following error appears
Not in scope : data constructor ‘S’
Note: There are some functions in each module for sure, I’m just skipping it for brevity
Assuming in reality the module name starts with an upper case letter, as it must, the empty export list –
()– says the module doesn’t export anything, so the things defined inFirstaren’t in scope inSecond.Completely omit the export list to export all top-level bindings, or list the exported entities in the export list
(the
(..)exports also the constructors ofSetType, without that, only the type would be exported).And use as
or, to limit the imports to specific types and constructors:
You can also indent the top level,
but that is ugly, and one can get errors due to miscounting the indentation easily.