Building with runtime flags using cabal and ghc

I have a program written in Haskell and intended to be compiled with GHC. The program scales very well on multiple cores, so enabling multithreading is very important. In my .cabal file I've added ghc-options: -O3 -threaded to link with the threaded runtime. The problem is that with this approach the user would need to run the program with foo +RTS -N , which seems a bit cryptic and not ve

使用cabal和ghc构建运行时标志

我有一个用Haskell编写的程序,打算用GHC编译。 该程序在多核上可以很好地扩展,因此启用多线程非常重要。 在我的.cabal文件中,我添加了ghc-options: -O3 -threaded来与线程运行时链接。 问题是用这种方法用户需要用foo +RTS -N来运行这个程序,这看起来有点神秘而且不太友好。 我怎样才能告诉cabal / ghc来隐藏这些运行时标志给用户? 我已阅读--with-rtsopts ,但GHC(7.0.3)只是在尝试使用它时吐出unrecognized flag

Is there any reason not to use the INLINABLE pragma for a function?

The documentation states: An {-# INLINABLE f #-} pragma on a function f has the following behaviour: While INLINE says "please inline me", the INLINABLE says "feel free to inline me; use your discretion". In other words the choice is left to GHC, which uses the same rules as for pragma-free functions. Unlike INLINE, that decision is made at the call site, and will theref

是否有任何理由不使用INLINABLE编译指示功能?

该文件指出: 函数f上的{ - #INLINABLE f# - }编译指示具有以下行为: 尽管INLINE表示“请将我内联”,但“可以插入”表示“可以随心所欲地使用您的自由裁量权”。 换句话说,选择留给GHC,它使用与无杂注函数相同的规则。 与INLINE不同,该决定是在呼叫站点进行的,因此将受到内联阈值,优化级别等的影响。 与INLINE一样,INLINABLE编译指示保留原始RHS的内联用途副本,并将其保存在接口文件中,而不管RHS的大小如何。 使

Style vs Performance Using Vectors

Here's the code: {-# LANGUAGE FlexibleContexts #-} import Data.Int import qualified Data.Vector.Unboxed as U import qualified Data.Vector.Generic as V {-# NOINLINE f #-} -- Note the 'NO' --f :: (Num r, V.Vector v r) => v r -> v r -> v r --f :: (V.Vector v Int64) => v Int64 -> v Int64 -> v Int64 --f :: (U.Unbox r, Num r) => U.Vector r -> U.Vector r -> U.Vector r f

使用向量的风格与性能

代码如下: {-# LANGUAGE FlexibleContexts #-} import Data.Int import qualified Data.Vector.Unboxed as U import qualified Data.Vector.Generic as V {-# NOINLINE f #-} -- Note the 'NO' --f :: (Num r, V.Vector v r) => v r -> v r -> v r --f :: (V.Vector v Int64) => v Int64 -> v Int64 -> v Int64 --f :: (U.Unbox r, Num r) => U.Vector r -> U.Vector r -> U.Vector r f :: U.Vect

GHC Core as "bytecode"?

As I understand it, GHC (the Glorious Glasgow Haskell Compiler) compiles Haskell to "Core", and then compiles that Core into machine code. Would it be at all practical to distribute Haskell programs as GHC Core, as if it were "bytecode"? Would there be any benefit to such a distribution? Why or why not? This wouldn't be practical; GHC Core is not portable. For examp

GHC核心为“字节码”?

据我了解,GHC(Glorious Glasgow Haskell编译器)将Haskell编译为“Core”,然后将该Core编译为机器代码。 将Haskell程序作为GHC Core来分发,就好像它是“字节码”一样吗? 这样的分配会有什么好处吗? 为什么或者为什么不? 这不可行; GHC Core不可移植。 例如,在32位机器上,64位算术编译为Core中的外部函数调用,但在64位机器上,它使用本机机器字算术。 更重要的是,GHC实际上不能读取Core; 它可以用几种格式打印出

Profile only a single function (or cost center) with GHC

I am trying to profile some Haskell code using the GHC profiling tools. The cost center I am most interested in, however, is dominated currently by a bunch of initialization code that I don't really care about. My code looks roughly, like this: main = do x <- lotsOfInitialization print $ {-# SCC "myCostCenter" #-} interestingPart x In my actual code, the lotsOfInitialization part

使用GHC只配置一个功能(或成本中心)

我正在尝试使用GHC分析工具来分析一些Haskell代码。 然而,我最感兴趣的成本中心目前主要是由一堆我并不关心的初始化代码。 我的代码大致如下所示: main = do x <- lotsOfInitialization print $ {-# SCC "myCostCenter" #-} interestingPart x 在我的实际代码中, lotsOfInitialization部分占用了大约98%的时间,因此很难以任何粒度查看interestingPart发生的事情。 我认为只在一个地方注释(而不是使用-fprof-

ambiguity error with `reads` in ghc

I am testing the code for Write yourself a Scheme in 48 hours with GHC-7.8.2, which gives me an error about ambiguity that I don't recall encountering in previous versions of GHC. The excerpt is below, with the problem line marked: data LispVal = Atom String | List [LispVal] | DottedList [LispVal] LispVal | Number Integer | String String

用ghc中的`reads`模糊错误

我正在测试使用GHC-7.8.2在48小时内编写自己的计划的代码,这给我一个关于模糊的错误,我不记得在以前版本的GHC中遇到过。 摘录如下,标有问题行: data LispVal = Atom String | List [LispVal] | DottedList [LispVal] LispVal | Number Integer | String String | Bool Bool unpackNum :: LispVal -> Integer unpackNum (Number n) = n unpackNum (Str

Haskell, Hackage, GHC and productivity. How to solve a real example?

I don't know the best way to solve a simple (probably) problems (hackage related). I asked for help about it (http://stackoverflow.com/questions/12841599/haskell-hackage-ghc-and-productivity-what-to-do) but I knew not explain well. Today, I'm with a this kin problem. The concrete problem isn't relevant, but is it: `Write a function that, given a string, remove diacritics.` Exa

Haskell,Hackage,GHC和生产力。 如何解决一个真实的例子?

我不知道解决一个简单(可能)问题的最佳方法(相关hackage)。 我询问有关它的帮助(http://stackoverflow.com/questions/12841599/haskell-hackage-ghc-and-productivity-what-to-do),但我知道解释不好。 今天,我遇到了这个亲属问题。 具体问题不相关,但它是: `Write a function that, given a string, remove diacritics.` 例: `simpleWord "Cigüeñal" <-> "Ciguenal" 正确的方式(我认为)是使用标准

How does the ST monad work?

I understand that the ST monad is something like a little brother of IO, which in turn is the state monad with added RealWorld magic. I can picture states and I can picture that RealWorld is somehow put into IO, but every time I write a type signature of ST the s of the ST monad confuses me. Take, for example, ST s (STArray sab) . How does the s work there? Is it just used to build up some a

ST monad如何工作?

我明白ST monad就像IO的一个小兄弟,反过来也是加入了RealWorld魔法的状态monad。 我可以描绘出状态,我可以想象RealWorld是以某种方式放入IO中的,但是每次我写ST的类型签名时,ST monad的s让我困惑。 以ST s (STArray sab)为例。 s在那里工作? 难道仅仅是用来建立计算之间的一些人为的数据依赖而不能像在状态单子(由于各州引用forall )? 我只是抛出想法,并非常感谢比我更懂事的人向我解释。 s使ST monad中的物体

Haskell: Lists, Arrays, Vectors, Sequences

I'm learning Haskell and read a couple of articles regarding performance differences of Haskell lists and (insert your language)'s arrays. Being a learner I obviously just use lists without even thinking about performance difference. I recently started investigating and found numerous data structure libraries available in Haskell. Can someone please explain the difference between Lis

Haskell:列表,数组,向量,序列

我正在学习Haskell并阅读了一些关于Haskell列表和(插入你的语言)列表的性能差异的文章。 作为一名学习者,我显然只是在不考虑性能差异的情况下使用列表。 我最近开始调查并发现了Haskell中的大量数据结构库。 有人可以解释列表,阵列,向量,序列之间的区别,而不会深入研究数据结构的计算机科学理论吗? 另外,是否有一些常见的模式可以使用一种数据结构而不是另一种? 是否还有其他任何形式的数据结构,我错过了并

Haskell do clause with multiple monad types

I'm using a graphic library in Haskell called Threepenny-GUI. In this library the main function returns a UI monad object. This causes me much headache as when I attempt to unpack IO values into local variables I receive errors complaining of different monad types. Here's an example of my problem. This is a slightly modified version of the standard main function, as given by Threepen

Haskell使用多个monad类型来执行子句

我在Haskell中使用一个名为Threepenny-GUI的图形库。 在这个库中,主函数返回一个UI monad对象。 这使我非常头疼,因为当我尝试将IO值解压到局部变量时,我收到了抱怨不同monad类型的错误。 这是我的问题的一个例子。 这是标准主函数的稍微修改版本,如Threepenny-GUI的代码示例所示: main :: IO () main = startGUI defaultConfig setup setup :: Window -> UI () setup w = do labelsAndValues <- shuffle [1..1