On 6/1/18 2:11 PM, Markus Klinik wrote:
> Dear Cleaners,
>
> I'm trying to import qualified Data.Set as Set, but when I try to use the
> type for a record field in a module, I get an error message that I don't
> understand.
>
> There are three files involved:
>
> Main.icl
>
> module Main
>
> import StdEnv
> import MyModule
> import qualified Data.Set as Set
>
> // This works
> :: MyRecord =
> { recordField :: 'Set'.Set Int
> }
>
> myRecord :: MyRecord
> myRecord = { recordField = 'Set'.newSet }
>
> Start = 10
>
>
> MyModule.dcl
>
> definition module MyModule
>
> import qualified Data.Set as Set
>
> // This doesn't work
> :: MyOtherRecord =
> { otherRecordField :: 'Set'.Set Int
> }
>
>
> MyModule.icl
>
> implementation module MyModule
>
> import qualified Data.Set as Set
>
>
> The record field MyRecord.recordField works fine. But the record field
> MyOtherRecord.otherRecordField gives two different error messages,
> depending on which file of MyModule.dcl and MyModule.icl has been
> modified last.
>
> If I modify MyModule.dcl and compile, I get this error message:
>
> Error [MyModule.dcl,5,Set]: not imported in implementation module (from
> Data.Set)
This happens if the main module is compiled first. When compiling
MyModule.icl the compiler finds a checked MyOtherRecord in the cache
from the definition module and can't find the import of ::Set in the
implementation module.
> If I modify MyModule.icl and compile, I get this error message:
>
> Error [MyModule.dcl,5,MyOtherRecord]: 'Set'.Set not imported
>
This happens if the implementation module is compiled first.
The compiler cannot find the import, because the qualified
names are collected by the parser, but the definition of
MyOtherRecord is copied from the definition module.
> If I additionally do, in both MyModule.dcl and MyModule.icl:
>
> from Data.Set import :: Set
>
> and use the type Set unqualified, it works. But the reason why I want to
> use the type qualified is because Gast also it's own Set implementation,
> and I want to use Gast and Data.Set in my program.
>
> Any ideas?
Add the type MyOtherRecord to MyModule.icl:
:: MyOtherRecord =
{ otherRecordField :: 'Set'.Set Int
}
The compiler copies type definitions that occur only in
the definition module to the implementation module. This
was implemented before qualified imports were added to
the compiler and apparently needs to be updated to
handle qualified names in these definitions.
Kind regards,
John van Groningen
_______________________________________________
clean-list mailing list
[email protected]
https://mailman.science.ru.nl/mailman/listinfo/clean-list