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

Disappearing qualified import #219

Closed
flupe opened this issue Nov 8, 2023 · 4 comments
Closed

Disappearing qualified import #219

flupe opened this issue Nov 8, 2023 · 4 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@flupe
Copy link
Contributor

flupe commented Nov 8, 2023

Minimal example of a bug I encountered with qualified imports.

A.agda:

module A where

open import Haskell.Prelude

X : Set
X ={-# COMPILE AGDA2HS X #-}

B.agda:

module B where

open import Haskell.Prelude

import A

X : Set
X = A.X

{-# COMPILE AGDA2HS X #-}

Compiling file B.agda yields:

module B where

import A (X)

type X = X

A is not imported qualified somehow.

@flupe flupe added the bug Something isn't working label Nov 8, 2023
@flupe flupe self-assigned this Nov 8, 2023
@flupe
Copy link
Contributor Author

flupe commented Nov 8, 2023

Don't know if this is intended behavior, but the current test case for qualified import does expect the qualification to disappear:

import Importee
simpqualBar : Int
simpqualBar = Importee.foo
{-# COMPILE AGDA2HS simpqualBar #-}
simpfoo : Importee.Foo
simpfoo = Importee.Foo.MkFoo
{-# COMPILE AGDA2HS simpfoo #-}

import Importee (Foo(MkFoo), foo)
import qualified QualifiedImportee as Qually (Foo, Fooable(defaultFoo, doTheFoo), foo, (!#))
-- ** simple qualification
simpqualBar :: Int
simpqualBar = foo
simpfoo :: Foo
simpfoo = MkFoo


Edit: introduced in #202 , before that things were qualified properly.

@omelkonian
Copy link
Contributor

Maybe worth looking at the "clashing-imports check":

https://github.com/agda/agda2hs/blob/master/test/Fail/ClashingImport.agda#L1-L12

(generally, the whole feature got introduced in PR #136)

This bug might suggest two possible solutions:

  1. Extend the check to also account for name clashing with definitions of this module.
  2. Treat import M in Agda as import qualified M as M in Haskell.

@flupe
Copy link
Contributor Author

flupe commented Nov 8, 2023

Gonna investigate. Personally I find your 2nd solution to be the most sensible choice.

@jespercockx
Copy link
Member

I agree with solution 2. A non-opened import really should be translated to a qualified import in Haskell.

flupe added a commit to flupe/agda2hs that referenced this issue Nov 8, 2023
@flupe flupe closed this as completed in 57811ed Nov 10, 2023
flupe added a commit to flupe/agda2hs that referenced this issue Nov 11, 2023
@jespercockx jespercockx added this to the 1.2 milestone Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants