3

Among other methods, there are a few most common ways to run a haskell program:

  • ghci, load the file, run main by hand from shell
  • runhaskell file.hs
  • ghc file.hs && ./file

I weren't able to find, however, how to run simple code from standard input / command arguments.

For example, standard Lua interpreter will allow you to do:

$ lua -e "print (2+2)"
4

What would be an equivalent of the above for a common Haskell Platform environment?

1
  • Would the downvoter please state the reason? Commented Oct 23, 2013 at 14:27

1 Answer 1

6

It's just the same.

$ ghc -e "print (2+2)"
4
Sign up to request clarification or add additional context in comments.

2 Comments

Now I feel a bit dumb, but that answer is a surprising food for thought about more Lua and Haskell similiarities.
@BartekBanachewicz It's not really Lua and Haskell similarities. More or less every compiler/interpreter has an interface like that on unixy systems. It's just a convention.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.