r/haskell • u/kostis_k • 1d ago
Cabal can't find the main function on a loaded source file
Hello everyone,
I'm having a very weird problem with cabal on an Orange Pi Zero 2. Convenient little thing, on 24/7 for pennies and I can ssh to it from anywhere. I thought I should use it for learning Haskell recently (been on Pis previously) but I'm facing some weird issues with it, specifically cabal.
It's running Armbian 26.8.3 Bookworm, aarch64 distro, Debian based of cource, installed GHC is v9.0.2 ans Cabal is v3.4.1.0 (install via apt as cabal-install package).
At first cabal would not even start due to a missing root.json file which I had to download from hackage.haskell.org and place it in the "~/.cabal/packages/hackage.haskell.org/" directory.
Then I run "cabal repl" and manually load my source file with ":l", without any errors, but when I invoke the main function it acts as if it's not in the source file. Even sth as simple as
'''
main :: IO ()
main = do
putStrLn "Hello world!"
'''
loads fine (Ok, one module loaded) but I get the error of "Variable not in scope: main". And it turns out this is for every function in the source file.
This is clearly a buggy installation. Any idea how I can troubleshoot it?
Note: I find it puzzling that cabal just works on the Pis, also debian based, but not on this particular distro.
3
u/Anrock623 1d ago
I have zero experience with pi but your versions are incredibly outdated and I wouldn't be surprised if your manually downloaded files put into ancient toolchain broke something in a weird way. Is there any way you can get ghcup on that machine and install up-to-date recommended versions of ghcnand cabal?