0
votes

I can load a single haskell file with a single function into ghci using :l addOne.hs

If I load another haskell file :l addTwo.hs it wipes the reference to the other and I get a Variable not in scope: addOne error when I try to call addOne

addOne.hs

addOne x = x + 1

addTwo.hs

addTwo x = x + 2

There are a few other posts that talk about loading multiple modules. Is the only way to achieve the above to convert them to modules and call

> :load Module1 Module2
> :module Module1 Module2
1
Maybe :script filename? - Chris Stryczynski

1 Answers

3
votes

Ref: https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-990005.1

An abbreviated form of module, consisting only of the module body, is permitted. If this is used, the header is assumed to be module Main(main) where.

I don't think you can have two identically named modules loaded into ghci (the real name of the module; you can have aliased qualified imports).