ghc

Haskell: How to only generate .hi file with ghc?

拈花ヽ惹草 提交于 2019-11-30 22:37:40
I would like to generate an .hi interface file and only that (no object file, no code generation at all). I tried ghc -fno-code -ohi out.hi myfile.hs and get ghc: -ohi can only be used when compiling a single source file which I don't understand since I have only given a single source file. Around 2014, there was an option added to GHC specifically for this. Now, you can invoke: ghc -fno-code -fwrite-interface ... It actually speeds up compilation by about a quarter in some cases. Use -c option, or else ghc wants to link, not just to compile: ghc -fno-code -ohi out.hi -c myfile.hs UPDATE: but

Why are Haskell/GHC executables so large in filesize? [duplicate]

与世无争的帅哥 提交于 2019-11-30 22:07:11
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Small Haskell program compiled with GHC into huge binary Recently I noticed how large Haskell executables are. Everything below was compiled on GHC 7.4.1 with -O2 on Linux. Hello World ( main = putStrLn "Hello World!" ) is over 800 KiB. Running strip over it reduces the filesize to 500 KiB; even adding -dynamic to the compilation doesn't help much, leaving me with a stripped executable around 400 KiB. Compiling

Code becomes slower as more boxed arrays are allocated

牧云@^-^@ 提交于 2019-11-30 21:34:25
问题 Edit: It turns out that things generally (not just array/ref operations) slow down the more arrays have been created, so I guess this might just be measuring increased GC times and might not be as strange as I thought. But I'd really like to know (and learn how to find out) what's happening here though, and if there's some way to mitigate this effect in code that creates lots of smallish arrays. Original question follows. In investigating some weird benchmarking results in a library, I

Haskell Error: parse error on input `='

冷暖自知 提交于 2019-11-30 19:59:54
Specs GHC 6.12.1 Mac OS X 10.6.4 x64 MacBook Pro Problem I'm having trouble using let syntax. The following code refuses to compile: module Main where main = let x = 1 y = 2 z = 3 in putStrLn $ "X = " ++ show x ++ "\nY = " ++ show y ++ "\nZ = " ++ show z I tried tabbing in y = 2 and z = 3 even more. No dice. (Undesirable) Solutions The only way I've gotten the code to compile is either Replacing hard tabs with spaces. Replacing the let clause with a where clause. Saizan on #haskell explains that the assignments in a let expression have to align, not let itself. As long as the assignments line

GHC package conflicts

限于喜欢 提交于 2019-11-30 19:53:06
I'm trying to compile the following code with GHC: module Test where import Maybe import Prelude hiding (null) import System.IO null = () main :: IO () main = putStrLn "Hello, world!" If I just run ghc Test.hs , I get: Could not find module `Maybe' It is a member of the hidden package `haskell98-2.0.0.1'. So I try ghc -package haskell98 Test.hs : Ambiguous module name `Prelude': it was found in multiple packages: base haskell98-2.0.0.1 It doesn't seem right, but I try ghc -package haskell98 -hide-package base Test.hs : Could not find module `System.IO' It is a member of the hidden package

Is it possible to produce stand alone haskell executable

萝らか妹 提交于 2019-11-30 19:22:30
Is there any way to produce stand alone haskell executable to run on different linux machines assuming the architecture is similar? Sorry I should have been clearer. The other machines might not have ghc installed on them - a bit like pyinstaller for python is what I was looking for? You can use the flags -static -optl-pthread -optl-static to avoid dynamically linked dependencies when compiling a Haskell project. This should help you run the compiled executable on two linux machines that do not have the exact same library versions. Yes it is possible. Just like with gcc-produced binaries, you

Haskell: How to only generate .hi file with ghc?

别说谁变了你拦得住时间么 提交于 2019-11-30 17:27:05
问题 I would like to generate an .hi interface file and only that (no object file, no code generation at all). I tried ghc -fno-code -ohi out.hi myfile.hs and get ghc: -ohi can only be used when compiling a single source file which I don't understand since I have only given a single source file. 回答1: Around 2014, there was an option added to GHC specifically for this. Now, you can invoke: ghc -fno-code -fwrite-interface ... It actually speeds up compilation by about a quarter in some cases. 回答2:

How can I compile a GUI executable with ghc?

[亡魂溺海] 提交于 2019-11-30 17:20:47
问题 I ported a little Haskell program I wrote from Mac to Windows. It's a GUI application (wxHaskell, compiled with ghc 6.12.1), so it does not need the command prompt window to open. It does so, anyway, so my question: What must I do so that the program starts without opening a prompt window first? Is there some ghc switch for this? 回答1: When using wxWidgets with cygwin, you can avoid having a console window appear by passing the -mwindows flag to the linker. You can tell GHC to pass flags to

Why does GHC consider the LHS *syntactically* when inlining?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 17:20:05
According to the GHC docs : ...GHC will only inline the function if it is fully applied, where "fully applied" means applied to as many arguments as appear (syntactically) on the LHS of the function definition. Where the example given is two semantically-equivalent definitions: comp1 :: (b -> c) -> (a -> b) -> a -> c {-# INLINE comp1 #-} comp1 f g = \x -> f (g x) comp2 :: (b -> c) -> (a -> b) -> a -> c {-# INLINE comp2 #-} comp2 f g x = f (g x) My questions: Is it only in the presence of INLINE pragmas that we get this strict behavior (i.e. strict syntactic view of LHS, RHS inlined w/out

Compiling ghc with -fPIC support

心不动则不痛 提交于 2019-11-30 17:19:22
I'm trying to install GHC with -fPIC support in Fedora. I've grabbed a source tarball since it seems no binary one has this. In Build.mk i've changed the quick build type to ifeq "$(BuildFlavour)" "quick" SRC_HC_OPTS = -H64m -O0 -fasm -fPIC GhcStage1HcOpts = -O -fasm -fPIC GhcStage2HcOpts = -O0 -fasm -fPIC GhcLibHcOpts = -O -fasm -fPIC SplitObjs = NO HADDOCK_DOCS = NO BUILD_DOCBOOK_HTML = NO BUILD_DOCBOOK_PS = NO BUILD_DOCBOOK_PDF = NO endif unfortunately, when compiling i still get the ld error ghc -fglasgow-exts --make -shared -oHs2lib.a /tmp/Hs2lib924498/Hs2lib.hs dllmain.o -static -fno