I am new to Haskell and using a Windows PC. I am trying to set up my GHCi interface so that I can write my code in my text editor before executing it using the GHCi.
Currently, my GHCi reads
$ ghci GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude>
According to this site, I have to save my Haskell files to the current directory or specify some other directory in order to access them. This is what I don't know how to do.
My Questions:
- How do I set the current directory?
- How do I get the GHCi to tell me what the path for current directory is so I can check what it is set at when I want to?
Please explain starting from the line
Prelude>
as noted above so that I can follow along.
Note:
The example Haskell code given was
file name: Main.hs
main = print(fac(20))
fac 0 = 1
fac n = n * fac(n-1)
and in the GHCi
prelude> :load Main
Compiling Main ( Main.hs, interpreted )
Ok, modules loaded: Main.
*Main> fac 17
355687428096000
So I want to save Main.hs to a directory, specify this as the current directory in the GHCi, and then run the above code.
ghci
? Are you runningghci
from the command line or some other method? – Gabriella Gonzalez:!cd
should give you the current directory, and:cd <dir>
should change directory to<dir>
. – jub0bsstack ghci
. – SwiftsNamesake