ghc - Running and compiling 'Hello, World!' in Haskell -


i new haskell , having issue running following code:

module main ( main )  main = putstrln "hello, world!" 

sublimehaskell tries compile , run above using

runhaskell hello.hs 

which returns error

hello.o: getmodificationtime: invalid argument (the system cannot find file specified.) 

i have tried run using

ghc --make hello.hs 

with same error. when try manually compile code before running using command line

ghc -c hello.hs 

i different error:

createdirectory ".": invalid argument (cannot create file when file exists.) 

on other hand, can run program via repl without issue:

ghci ghci, version 8.0.1: http://www.haskel.org/ghc/  :? prelude> putstrln "hello, world!" hello, world! 

if it's relevant, using windows 7, , installed ghc using haskell platform installer.

***edit running above commands -v flag gives following results:

ghc -v hello.hs  glasgow haskell compiler, version 8.0.1, stage 2 booted ghc version     7.10.2 using binary package database: c:\program files\haskell      platform\8.0.1\lib\package.conf.d\package.cache loading package database c:\program files\haskell    platform\8.0.1\lib\package.conf.d wired-in package ghc-prim mapped ghc-prim-0.5.0.0 wired-in package integer-gmp mapped integer-gmp-1.0.0.1 wired-in package base mapped base-4.9.0.0 wired-in package rts mapped rts wired-in package template-haskell mapped template-haskell-2.11.0.0 wired-in package ghc mapped ghc-8.0.1 wired-in package dph-seq not found. wired-in package dph-par not found. hsc static flags: loading package database c:\program files\haskell     platform\8.0.1\lib\package.conf.d wired-in package ghc-prim mapped ghc-prim-0.5.0.0 wired-in package integer-gmp mapped integer-gmp-1.0.0.1 wired-in package base mapped base-4.9.0.0 wired-in package rts mapped rts-1.0 wired-in package template-haskell mapped template-haskell-2.11.0.0 wired-in package ghc mapped ghc-8.0.1 wired-in package dph-seq not found. wired-in package dph-par not found. *** chasing dependencies: chasing modules from: *hello.hs *** deleting temp files: deleting: *** deleting temp dirs: deleting: hello.o: getmodificationtime: invalid argument (the system cannot find file specified.)  ghc -c -v hello.hs  glasgow haskell compiler, version 8.0.1, stage 2 booted ghc version 7.10.2 using binary package database: c:\program files\haskell     platform\8.0.1\lib\package.conf.d\package.cache loading package database c:\program files\haskell    platform\8.0.1\lib\package.conf.d wired-in package ghc-prim mapped ghc-prim-0.5.0.0 wired-in package integer-gmp mapped integer-gmp-1.0.0.1 wired-in package base mapped base-4.9.0.0 wired-in package rts mapped rts wired-in package template-haskell mapped template-haskell-2.11.0.0 wired-in package ghc mapped ghc-8.0.1 wired-in package dph-seq not found. wired-in package dph-par not found. hsc static flags: *** checking old interface main: *** parser [main]: !!! parser [main]: finished in 0.00 milliseconds, allocated 0.067 megabytes *** renamer/typechecker [main]: !!! renamer/typechecker [main]: finished in 46.80 milliseconds, allocated  15.720 megabytes *** desugar [main]: result size of desugar (after optimization) = {terms: 13, types: 6, coercions: 0} !!! desugar [main]: finished in 0.00 milliseconds, allocated 0.204 megabytes *** simplifier [main]: result size of simplifier iteration=1 = {terms: 17, types: 8, coercions: 0} result size of simplifier = {terms: 17, types: 8, coercions: 0} !!! simplifier [main]: finished in 0.00 milliseconds, allocated 0.171  megabytes *** coretidy [main]: result size of tidy core = {terms: 17, types: 8, coercions: 0} !!! coretidy [main]: finished in 0.00 milliseconds, allocated 2.558  megabytes *** deleting temp files: deleting: *** deleting temp dirs: deleting: createdirectory ".": invalid argument (cannot create file when file exists.) 

after looking around, seems 2 packages listed not found (dph-seq , dph-par) have been deprecated.

ghc requires file named same module in order compile it. however, module can loaded ghci regardless of file name. why repl worked compiling did not.

in case, therefore, should rename file main.hs


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -