0
votes

This is similar to the question at stack ghci not loading up local modules? but not exactly the same.

I have a directory with the files Main.hs and Shapes.hs where Main.hs has a reference to the module Shapes.

If I run

ghci Main.hs

everything works fine. This is version 7.10.

But if I run, in version 8,

stack ghci

:load Main.hs

I get the error

[1 of 1] Compiling Main ( Main.hs, interpreted )

Main.hs:3:1: error:

Failed to load interface for ‘Shapes’

It is not a module in the current program, or in any known package.

Failed, modules loaded: none.

I tried the solution on the link

:load Shapes.hs Main.hs

but it still does not work. I get the error

[1 of 2] Compiling Shapes ( Shapes.hs, interpreted )

[2 of 2] Compiling Main ( Main.hs, interpreted )

Main.hs:1:1: error:

The IO action ‘main’ is not defined in module ‘Main’

Failed, modules loaded: Shapes.

I found the following which discusses this second matter:

How to avoid "‘main’ is not defined in module ‘Main’" when using syntastic

But if I were to put in

main :: IO ()

in the Main.hs file, I still get errors. If I were to additionally add the line

main = return ()

and have these two additional lines at the end, then it would load. But after loading it just exits main and I no longer have access to the functions in main. I don't see any reason why I need to use any IO features when I import some other module. How do I, in version 8, load a local module without using IO?

1

1 Answers

0
votes

I fixed my own problem. There was a line in Main.hs at the top called

module Main where

that I removed. Now it works if I load in stack ghci with

:l Main.hs Shapes.hs