user2999787
user2999787

Reputation: 637

Calling Haskell script on mac?

I've installed the Haskell platform on my mac (OSX lion), and ghci is running great.

Now I've created a haskell-file, stored on my "desk." How can I call it from this directory?

Example:

Prelude> :load datei.hs
[1 of 1] Compiling Main             ( datei.hs, interpreted )

datei.hs:1:7: parse error on input `\'
Failed, modules loaded: none.

datei.hs:

let fac n = if n == 0 then 1 else n * fac (n-1)

Why do I get this?

Upvotes: 1

Views: 236

Answers (3)

user3011398
user3011398

Reputation:

If your already in ghci you can use ':cd /path/to/file' as well.

Here is a good thread discussing let.

Upvotes: 0

amindfv
amindfv

Reputation: 8458

If you saved your program with TextEdit, it's very possible that you're seeing a '\' character because you're saving it as an RTF file (TextEdit's default). Hit Ctrl-shift-t to convert it into a plain text file.

Upvotes: 1

Rob
Rob

Reputation: 5286

Use the OSX terminal to reach your desktop and invoke yourfile.hs using ghci:

cd ~/Desktop
ghci yourfile.hs

edit:

As stated in the comments, the error message you're seeing above is warning you that the character \ exists at an unexpected location in the source code.

Since that character does not exist in the line of code you posted, there must be more to datei.hs. We need to see the rest of your source code before we can help.

Upvotes: 1

Related Questions