Friday, 29 April 2016

Haskell: Hello World program using runghc command

'runghc' command comes with Haskell distribution, used to run Haskell programs without compiling.

Syntax
runghc [runghc flags] [GHC flags] module [program args]


Use the command 'runghc --help', to get more information about the command runghc.
$ runghc --help
Usage: runghc [runghc flags] [GHC flags] module [program args]

The runghc flags are
    -f /path/to/ghc       Tell runghc where GHC is
    --help                Print this usage information
    --version             Print version number


hello_world.hs
main = putStrLn ("hello, world")


$ runghc hello_world.hs
hello, world

It is not necessary to use ‘.hs’ extension after the Haskell file name.    
$ runghc hello_world
hello, world




Previous                                                 Next                                                 Home

No comments:

Post a Comment