8
我是新来的Haskell时遇到运行下面的代码的问题:运行并编译'Hello,World!'在Haskell
module Main (
main
) where
main = putStrLn "Hello, world!"
SublimeHaskell尝试编译并运行上述使用
runhaskell hello.hs
返回错误
hello.o: getModificationTime: invalid argument (The system cannot find the file specified.)
我也试着用它运行它
ghc --make hello.hs
与相同的错误。当我尝试手工编译的代码中使用命令行
ghc -c hello.hs
运行前,我收到了不同的错误:
CreateDirectory ".": invalid argument (Cannot create a file when that file already exists.)
在另一方面,我可以通过没有问题的REPL运行程序:
ghci
GHCi, version 8.0.1: http://www.haskel.org/ghc/ :? for help
Prelude> putStrLn "Hello, world!"
Hello, world!
如果是相关的,我使用的是Windows 7,我用哈斯克尔平台安装程序安装GHC。
***编辑与-v
标志运行上述命令的结果如下:
ghc -v hello.hs
Glasgow Haskell Compiler, Version 8.0.1, stage 2 booted by 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 to ghc-prim-0.5.0.0
wired-in package integer-gmp mapped to integer-gmp-1.0.0.1
wired-in package base mapped to base-4.9.0.0
wired-in package rts mapped to rts
wired-in package template-haskell mapped to template-haskell-2.11.0.0
wired-in package ghc mapped to 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 to ghc-prim-0.5.0.0
wired-in package integer-gmp mapped to integer-gmp-1.0.0.1
wired-in package base mapped to base-4.9.0.0
wired-in package rts mapped to rts-1.0
wired-in package template-haskell mapped to template-haskell-2.11.0.0
wired-in package ghc mapped to 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 the file specified.)
ghc -c -v hello.hs
Glasgow Haskell Compiler, Version 8.0.1, stage 2 booted by 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 to ghc-prim-0.5.0.0
wired-in package integer-gmp mapped to integer-gmp-1.0.0.1
wired-in package base mapped to base-4.9.0.0
wired-in package rts mapped to rts
wired-in package template-haskell mapped to template-haskell-2.11.0.0
wired-in package ghc mapped to ghc-8.0.1
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags:
*** Checking old interface for 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 a file when that file already exists.)
环顾四周后,似乎被列为两个包未找到(dph-seq
和dph-par
)有已被弃用。
嗯,是的,它肯定是有关您正在使用Windows 7,所以是Haskell的生态系统 - 你怎么安装GHC?随着堆栈,或其他方式? ......我知道我不应该这样做,但我不禁建议只是改用一些Linux发行版来摆脱这种麻烦。 (但是我听说即使在Windows上,堆栈GHC也应该很容易,所以...) – leftaroundabout
您的驱动器已满吗? –
不幸的是,我一直在使用Haskell平台安装程序安装GHC,但我一直坚持使用Windows。驱动器没有满 - 剩余8GB的空间。 – Fortunato