Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix #219] always qualify unopened imports #220

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Agda2Hs/Compile/Name.hs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ compileQName f
(C.Qual as C.QName{} : _) -> liftTCM $ do
let qual = hsModuleName $ prettyShow as
lookupModuleInCurrentModule as >>= \case
(x:_) | qual /= mod -> isDatatypeModule (amodName x) >>= \case
Just{} -> return $ QualifiedAs Nothing
Nothing -> return $ QualifiedAs $ Just qual
_ -> return Nothing
(x:_) | qual /= mod -> do
isDataMod <- isJust <$> isDatatypeModule (amodName x)
return $ QualifiedAs (if isDataMod then Nothing else Just qual)
_ -> return $ QualifiedAs Nothing
Comment on lines +154 to +156
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed that's much clearer / easier to read.

`catchError` \_ -> return $ QualifiedAs Nothing
_ -> return $ QualifiedAs Nothing

Expand Down
4 changes: 4 additions & 0 deletions test/QualifiedImports.agda
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ qualFooable = Qually.doTheFoo
qualDefaultBar : Qually.Foo
qualDefaultBar = Qually.defaultFoo
{-# COMPILE AGDA2HS qualDefaultBar #-}

Foo : Set
Foo = Importee.Foo
{-# COMPILE AGDA2HS Foo #-}
10 changes: 6 additions & 4 deletions test/golden/QualifiedImports.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module QualifiedImports where

import Importee (Foo(MkFoo), foo)
import qualified Importee (Foo(MkFoo), foo)
import qualified QualifiedImportee as Qually (Foo, Fooable(defaultFoo, doTheFoo), foo, (!#))

-- ** simple qualification

simpqualBar :: Int
simpqualBar = foo
simpqualBar = Importee.foo

simpfoo :: Foo
simpfoo = MkFoo
simpfoo :: Importee.Foo
simpfoo = Importee.MkFoo

-- ** qualified imports

Expand All @@ -25,3 +25,5 @@ qualFooable = Qually.doTheFoo
qualDefaultBar :: Qually.Foo
qualDefaultBar = Qually.defaultFoo

type Foo = Importee.Foo

Loading