How to match newlines with Alex/Haskell

I borrowed the example presented here http://www.haskell.org/alex/doc/html/introduction.html I am trying to make an interpreter for numerical expressions. (literals only, no variables) And I want to have newlines separate two different expressions. Unfortunaltely, when I do this $ignoredWhite = [tfvr] -- ignored whitespace $newline = "n" --new line Alex (v 2.2) aborts compil

如何将换行符与Alex / Haskell进行匹配

我借用了这里介绍的例子 http://www.haskell.org/alex/doc/html/introduction.html 我正在尝试为数字表达式做一个解释器。 (只有文字,没有变量)而我希望换行符分隔两个不同的表达式。 不幸的是,当我这样做 $ ignoredWhite = [ t f v r] - 忽略空白 $ newline =“ n” - 新行 亚历克斯(2.2版)中止汇编。 我努力了 $ newline = n - 新行 但是当它读取输入时,这只会导致中止从alex转移到最终的二进制文

ghci: keep defined values in scope after module reload

I am wondering if it is possible to keep assigned values in ghci when a module is reloaded? For example i assign a value in ghci: ghci> let x = 1 or ghci> x <- getLine After entering :r to reload an existing module x is not in scope anymore. Is it generally possible to keep the assignment available, like for example in the Python interpreter? (this is really convenient...) Even

ghci:在模块重新加载后,将定义的值保留在范围内

我想知道在模块重新加载时是否可以保留ghci中的赋值? 例如,我用ghci赋值: ghci> let x = 1 要么 ghci> x <- getLine 输入后:r重新加载现有模块x不在范围内。 通常可以保留赋值,例如在Python解释器中? (这真的很方便...) 即使实际上ghci中的每一行代表一个函数(单调地)绑定到下一个函数,我仍然想知道是否可以保持这个状态。 我不知道有这样做的任何方式。 麻烦的是,你可能有一些绑定到特定类型

Haskell GHC build error: Loading archives not supported

I'm trying to link a foreign cpp library with haskell. Running stack build seems to build it correctly but when I try to run stack repl I get this error: ghc: panic! (the 'impossible' happened) (GHC version 8.0.1 for x86_64-unknown-linux): Loading archives not supported app.cabal executable app-server ... include-dirs: /usr/local/include extra-libraries: symengine stdc++ gmpxx

Haskell GHC构建错误:加载不支持的档案

我正尝试将一个外部cpp库与haskell链接起来。 运行stack build似乎正确构建它,但是当我尝试运行stack repl此错误: ghc: panic! (the 'impossible' happened) (GHC version 8.0.1 for x86_64-unknown-linux): Loading archives not supported app.cabal executable app-server ... include-dirs: /usr/local/include extra-libraries: symengine stdc++ gmpxx gmp ... stack.yml flags: {} packages: - '.'

How do I install dependencies when cross compiling haskell code?

I've successfully created a ghc cross compiler, that allows me to compile haskell code for armv6h (raspberry pi in my case) from my x64 linux machine. I've successfully run a hello world program on the raspberry. No I want to build my real app, which has a lot of dependencies on other haskell modules. When I compile for x64 I simply do cabal install dependenciy1 depenency2 ... I kno

如何在交叉编译haskell代码时安装依赖关系?

我已经成功创建了一个ghc交叉编译器,它允许我从我的x64 linux机器上编译armv6h(在我的例子中是raspberry pi)的haskell代码。 我已经在树莓上成功运行了一个hello world程序。 不,我想构建我的真实应用程序,它对其他haskell模块有很大的依赖性。 当我为x64编译时,我只是做 cabal install dependenciy1 depenency2 ... 我知道我可以将自己的程序设计为cabal-project这一步的自动化。 但这不是重点。 当我尝试使用交

How to install a 32

I'm running Ubuntu Precise with an amd64 kernel and amd64 userland. I've just installed Haskell using sudo apt-get install haskell-platform . Now I'd like to install a binary using cabal install ... . However, that generates an amd64 binary. How is it possible to make Cabal generate an i386 binary (eg like gcc -m32 ) without creating a chroot of a full i386 Ubuntu system (using de

如何安装32

我使用amd64内核和amd64用户域运行Ubuntu Precise。 我刚刚使用sudo apt-get install haskell-platform安装了Haskell。 现在我想安装一个使用cabal install ...的二进制文件cabal install ... 但是,这会生成一个amd64二进制文件。 如何在不创建完整i386 Ubuntu系统的chroot(使用debootstrap)或创建虚拟机或在i386用户空间上运行它的情况下,使Cabal生成i386二进制文件(例如gcc -m32 )? 您可以从官方下载网站获得GHC

How can I get a strict accumArray?

I have a list of key-value pairs and I want to count how many times each key occurs and what values it occurs with, but when I try, I get a stack overflow. Here's a simplified version of the code I'm running: import Array add (n, vals) val = n `seq` vals `seq` (n+1,val:vals) histo = accumArray add (0,[]) (0,9) [(0, n) | n <- [0..5000000]] main = print histo When I compile this with

我怎样才能得到一个严格的accumArray?

我有一个键值对的列表,我想计算每个键出现的次数以及它出现的值,但是当我尝试时,出现堆栈溢出。 以下是我正在运行的代码的简化版本: import Array add (n, vals) val = n `seq` vals `seq` (n+1,val:vals) histo = accumArray add (0,[]) (0,9) [(0, n) | n <- [0..5000000]] main = print histo 当我用'ghc -O'编译这个并运行它时,我得到“堆栈空间溢出:当前大小8388608字节。” 我想我知道发生了什么:acc

Haskell Linear Algebra Matrix Library for Arbitrary Element Types

well, I'm note really sure how much relevant my answer is but Im having good experiences with GNU GSL library and there is a wrapper for haskel: http://hackage.haskell.org/package/bindings-gsl Check it out, maybe it will help you

用于任意单元类型的Haskell线性代数矩阵库

好吧,我很确定我的答案有多相关,但是我对GNU GSL库有很好的体验,并且haskel有一个包装: http://hackage.haskell.org/package/bindings-gsl 看看它,也许它会帮助你

Finite Field Linear Algebra Library for Haskell

Your best bet would be a binding to FFLAS/FFPACK, that represents the data in native Haskell types. However, I can't see that we have such a binding yet. Related libraries that would be a good starting point: http://hackage.haskell.org/package/vect http://hackage.haskell.org/package/hmatrix http://hackage.haskell.org/package/jalla http://hackage.haskell.org/package/blas For getti

Haskell的有限域线性代数库

你最好的选择是绑定到FFLAS / FFPACK,它表示本地Haskell类型的数据。 但是,我看不到我们有这样的绑定。 相关的图书馆将是一个很好的起点: http://hackage.haskell.org/package/vect http://hackage.haskell.org/package/hmatrix http://hackage.haskell.org/package/jalla http://hackage.haskell.org/package/blas 为了开始使用数组结构,矢量教程并不错: http://www.haskell.org/haskellwiki/Numeric_Haske

dependent event processing with state updates

I want to use FRP (ie, reactive banana 0.6.0.0) for my project (a GDB/MI front-end). But I have troubles declaring the event network. There are commands from the GUI and there are stop events from GDB. Both need to be handled and handling them depends on the state of the system. My current approach looks like this (I think this is the minimum required complexity to show the problem): data

依赖于状态更新的事件处理

我想为我的项目(一个GDB / MI前端)使用玻璃钢(即反应性香蕉0.6.0.0)。 但我有麻烦宣布事件网络。 有来自GUI的命令,还有来自GDB的停止事件。 两者都需要处理和处理它们取决于系统的状态。 我目前的方法是这样的(我认为这是显示问题所需的最低复杂度): data Command = CommandA | CommandB data Stopped = ReasonA | ReasonB data State = State {stateExec :: Exec, stateFoo :: Int} data StateExec = Running |

Calling haskell code from OCaml using FFI

I would like to expose a function from a Haskell source library using FFI and use it in OCaml code. I saw various examples using the foreign export ccall syntax in Haskell which I believe exports the function for usage in C. Is there something similar for OCaml? What would be the best approach to achieve this?

使用FFI从OCaml调用haskell代码

我想从使用FFI的Haskell源库中公开一个函数并在OCaml代码中使用它。 我看到了各种使用Haskell中的foreign export ccall语法的例子,我相信这些例子在C中导出了用法。对于OCaml有没有类似的东西? 什么是实现这一目标的最佳方法?