Nightshade
Nightshade

Reputation: 334

How can I load a source file into Haskell (ghci)?

I have created a file in text edit on mac called: 1stfunctionite.hs with the function:

doubleX x = x + x 

Then saved it to my documents. I then went onto terminal called ghci and entered

:l 1stfunctionite

Into the prelude, however, an error message came up of:

target ‘1stfunctionite is not a module name or a source file 

How can I create a source file with this function inside so i can use it within terminal in prelude?

Upvotes: 4

Views: 2650

Answers (2)

Ellen Spertus
Ellen Spertus

Reputation: 6815

Another solution is to cd into the directory containing your files before running ghci.

Upvotes: 1

ThreeFx
ThreeFx

Reputation: 7360

You have to be in the same directory for it to work, just do :cd <your directory> in ghci and you will be fine.

Upvotes: 4

Related Questions