toyboot4e / ac-library-hs

[WIP] Haskell port of ac-library.
Creative Commons Zero v1.0 Universal
4 stars 0 forks source link

Word-based bundler with qualified imports #2

Open toyboot4e opened 1 month ago

toyboot4e commented 1 month ago

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 commented 1 month ago

Initial plan:

toyboot4e commented 2 weeks ago

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.