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

Word-based bundler with qualified imports #2

Open
toyboot4e opened this issue Sep 26, 2024 · 3 comments
Open

Word-based bundler with qualified imports #2

toyboot4e opened this issue Sep 26, 2024 · 3 comments

Comments

@toyboot4e
Copy link
Owner

Allow qualified imports in user-defined libraries and bundle them into a single Main.hs before submission.

Simple word-based replacement doesn't fully resolve name conflicts, but it's better than nothing!

@toyboot4e
Copy link
Owner Author

toyboot4e commented Sep 29, 2024

Initial plan:

  • Qualified imports have a global scope among all user source files.
  • Types, record filed names and functions get file-based scopes with the simple word replace.

@toyboot4e
Copy link
Owner Author

Alternative approach is hacking the judge environment.

Here's an example submission code, where {- AC_PROJECT <path> -} denotes a file distribution:

{- AC_PROJECT src/MyLib/F.hs -}
module F (f) where

f :: Int -> Int
f = (+ 1)

{- AC_PROJECT app/Main.hs -}
import MyLib.F qualified as F
main :: IO ()
main = print $ f 1

It would expand to such a project:

.
├── app/
│   └── Main.hs
└── src/
    └── MyLib/
        └── F.hs

Then we can use real qualified imports. Ridiculous, cheating.. but actually solid.

@toyboot4e
Copy link
Owner Author

The hacking judge approach was not accepted by the AtCoder administrators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant