ghc

Haskell dynamic library

强颜欢笑 提交于 2020-01-10 01:43:06
问题 http://www.vex.net/~trebla/haskell/so.xhtml describes how to compile shared library. About compiling command: ghc -O2 -dynamic -shared -fPIC -o libEval.so Eval.hs hsbracket.c -lHSrts-ghc7.6.3 it says: (Could you omit -dynamic to request static libraries of other packages? Not really, they were not generated with -fPIC. In particular it is illegal on x86_64.) Why is it so? What should one do to compile shared library without libHS* dependencies? 回答1: Since Kaiko contacted me privately for an

Debug GHC compilation error returned at runtime by hint's `Language.Haskell.Interpreter.runInterpreter`

倾然丶 夕夏残阳落幕 提交于 2020-01-05 04:11:07
问题 I've re-posted this question to focus more tightly on the specific error, and to better enumerate what I've already tried. I'm trying to parse some Haskell code during the runtime of a Haskell program using the hint package. The outer program compiles, but when I run it the inner compilation step fails. I'm getting a description of what I assume is a syntax problem, and a location in the "interactive" code, but I have no idea how to view the code in question. Here's Main.hs module Main where

Criterion causing memory consumption to explode, no CAFs in sight

无人久伴 提交于 2020-01-04 15:32:02
问题 Basically I have a simple function call, which when used in conjunction with Criterion, results in the memory consumption exploding. Suppose I have the following program : {-# OPTIONS_GHC -fno-cse #-} {-# LANGUAGE BangPatterns #-} module Main where import Criterion.Main import Data.List num :: Int num = 10000000 lst :: a -> [Int] lst _ = [1,2..num] myadd :: Int -> Int -> Int myadd !x !y = let !result = x + y in result mysum = foldl' myadd 0 main :: IO () main = do print $ mysum (lst ()) Then

Keeping track of history in ghci

你说的曾经没有我的故事 提交于 2020-01-04 07:13:18
问题 How does history management work in GHCI or other Haskell-based REPLs? Since Haskell is a pure language, I guess it's implemented using a monad, perhaps the state monad. Kindly note I'm a beginner in Haskell, so please provide a detailed explanation rather than just linking to the source. 回答1: This is a simplified example of how a program might keep a history of commands entered by the user. It basically has the same structure as the number guessing game, so once you understand that you

Keeping track of history in ghci

半腔热情 提交于 2020-01-04 07:11:29
问题 How does history management work in GHCI or other Haskell-based REPLs? Since Haskell is a pure language, I guess it's implemented using a monad, perhaps the state monad. Kindly note I'm a beginner in Haskell, so please provide a detailed explanation rather than just linking to the source. 回答1: This is a simplified example of how a program might keep a history of commands entered by the user. It basically has the same structure as the number guessing game, so once you understand that you

GHC Foreign hs_init/hs_add_root crashes

孤街浪徒 提交于 2020-01-03 21:48:09
问题 I don't repeat more than necessary, brief summary: Following the Adder example from this tutorial on a machine with win7 (64) with VS 2010. But I don't use C++ but plain C. When using the cl (MS compiler) with cl /Zi (and no other flag) it works like expected. If not use /Zi and then try to execute the exe goes into flames. Why? (There must be some compiler/link options that make some init in the start of the haskell dll go wrong ) EDIT: Some investigation: /Zi does not affect optimizations.

GHC Foreign hs_init/hs_add_root crashes

廉价感情. 提交于 2020-01-03 21:47:04
问题 I don't repeat more than necessary, brief summary: Following the Adder example from this tutorial on a machine with win7 (64) with VS 2010. But I don't use C++ but plain C. When using the cl (MS compiler) with cl /Zi (and no other flag) it works like expected. If not use /Zi and then try to execute the exe goes into flames. Why? (There must be some compiler/link options that make some init in the start of the haskell dll go wrong ) EDIT: Some investigation: /Zi does not affect optimizations.

Hint.interpret gives a compiler error when used on a Polysemy.Sem value

你。 提交于 2020-01-03 19:37:16
问题 The bounty expires in 3 days . Answers to this question are eligible for a +50 reputation bounty. ShapeOfMatter wants to draw more attention to this question: “I'm still not sure how to move forward on this.” I'm trying to compile Polysemy monad values at runtime using Hint (Language.Haskell.Interpreter). When I try to do this I reliably get an error about improper use of the : operator in "interactive" code; it seems as if the text hint is passing to GHC has a syntax error in it. {-#

Hint.interpret gives a compiler error when used on a Polysemy.Sem value

这一生的挚爱 提交于 2020-01-03 19:34:56
问题 The bounty expires in 3 days . Answers to this question are eligible for a +50 reputation bounty. ShapeOfMatter wants to draw more attention to this question: “I'm still not sure how to move forward on this.” I'm trying to compile Polysemy monad values at runtime using Hint (Language.Haskell.Interpreter). When I try to do this I reliably get an error about improper use of the : operator in "interactive" code; it seems as if the text hint is passing to GHC has a syntax error in it. {-#

Duplicate definition for symbol __module_registered error

大兔子大兔子 提交于 2020-01-03 16:48:14
问题 I get an error message from GHCi about a "duplicate definition for symbol __module_registered", like this: GHCi runtime linker: fatal error: I found a duplicate definition for symbol __module_registered whilst processing object file /usr/local/lib/ghc-6.2/HSfgl.o How to fix this? 回答1: Thats is easy, probably indicates that when building a library for GHCi (HSfgl.o in the above example), you should use the -x option to ld. 来源: https://stackoverflow.com/questions/3392925/duplicate-definition