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

Importing a name from a module Haskell.* should generate import #391

Closed
HeinrichApfelmus opened this issue Jan 23, 2025 · 3 comments · Fixed by #392
Closed

Importing a name from a module Haskell.* should generate import #391

HeinrichApfelmus opened this issue Jan 23, 2025 · 3 comments · Fixed by #392
Assignees
Labels
bug Something isn't working
Milestone

Comments

@HeinrichApfelmus
Copy link
Contributor

HeinrichApfelmus commented Jan 23, 2025

I would like to import an external Haskell module, say, Data.ByteString. However, I am unable to generate the corresponding Haskell import statement.

More specifically: After #379 , I can create an Agda wrapper module Haskell.Data.ByteString

-- agda
module Haskell.Data.ByteString where

postulate
  ByteString : Set

However, when using this module, say, as

-- agda
module Test where

open import Haskell.Data.ByteString using (ByteString)

test : ByteString  ByteString
test x = x

{-# COMPILE AGDA2HS test #-}

the transpilation output is

-- Haskell
module Test where

test :: ByteString -> ByteString
test x = x

This is not what I had in mind, though — I was hoping that the transpilation output would include the import statement.

import Data.ByteString (ByteString)

As a workaround, I can add this import manually with FOREIGN AGDA2HS in the module Test, but this module is not the right place — ideally, I should be able to specify in Haskell.Data.ByteString that the postulated ByteString type is a Haskell identifier that comes from the module Data.ByteString.

@HeinrichApfelmus
Copy link
Contributor Author

HeinrichApfelmus commented Jan 23, 2025

Solving this issue would allow me to contribute Haskell functions modules that are outside of the Prelude, such as:

  • Additions to Data.List such as foldl', nub, …
  • Additions to Data.Maybe such as isJust, catMaybes, …
  • Axiomatization of Data.Set
  • Axiomatization of Data.Map

Related issue: #377

@jespercockx
Copy link
Member

Ah yes this is a rather important omission in my PR. It should be easy to fix, let me take a look!

@jespercockx jespercockx added the bug Something isn't working label Jan 24, 2025
@jespercockx jespercockx added this to the 1.4 milestone Jan 24, 2025
@jespercockx jespercockx self-assigned this Jan 24, 2025
jespercockx added a commit to jespercockx/agda2hs that referenced this issue Jan 24, 2025
@HeinrichApfelmus
Copy link
Contributor Author

Thank you for the quick fix!

The original issue appears to be fixed, but there is a new issue when the imported module contains postulate instance: #394.

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

Successfully merging a pull request may close this issue.

2 participants