I'm using the FFI in order to use a function in C that takes a struct and returns the same struct. The references I saw say I have to use pointers to these structures in order to be able to import it into Haskell. So, for example. data Bar = Bar { a :: Int, b :: Int } type BarPtr = Ptr (Bar) foreign import ccall "static foo.h foo" f_foo :: BarPtr -> BarPtr Now I have the problem t
我正在使用FFI来使用C中的一个函数,该函数接受一个结构并返回相同的结构。 我看到的参考文献说,我必须使用指向这些结构的指针才能将其导入到Haskell中。 所以,例如。 data Bar = Bar { a :: Int, b :: Int } type BarPtr = Ptr (Bar) foreign import ccall "static foo.h foo" f_foo :: BarPtr -> BarPtr 现在我遇到了必须能够使用该功能的问题。 我看到的引用具有类型BarPtr - > IO()的函数,并且与具有
I maintain the augeas FFI library at http://hackage.haskell.org/package/augeas Recently augeas added an aug_to_xml method that includes a parameter with type xmlNode from libmxl2. It looks like libxml is the FFI library for libxml2, but it hasn't been updated in a while, and it doesn't look to have Debian packaging, so I'm hesitant to add it as a dependency to the augeas FFI librar
我在http://hackage.haskell.org/package/augeas上维护augeas FFI库 最近,augeas添加了一个aug_to_xml方法,其中包含一个来自libmxl2的类型为xmlNode的参数。 它看起来像libxml是libxml2的FFI库,但它并没有在一段时间内更新,并且它没有看到Debian的打包,所以我很犹豫是否将它作为依赖添加到augeas FFI库中。 所以我的问题是,当我为这个函数添加FFI支持时,将依赖项添加到libxml会更好吗,这可能会导致稍后打包问题,或
i need to know how can i resolve Unions and Type** (eg int**) with the FFI? I know that i need a Storable instance for structs, could i use it for unions too? a union like so: typedef union { int i; char c; } my_union; This would typically be represented in Haskell as: data MyUnion = I CInt | C CChar My question is how would you marshall (define an Storable instance for) myUnion
我需要知道如何解析工会和键入**(例如int **)与FFI? 我知道我需要一个可存储结构的实例,我可以将它用于工会吗? 这样的联盟: typedef union { int i; char c; } my_union; 这通常会在Haskell中表示为: data MyUnion = I CInt | C CChar 我的问题是你将如何marshall(为myUnion定义一个Storable实例)到my_union中? 我的理解是my_union会在内存中占用sizeof(int)个字节,即它的最大成员的大小。 所以
I would like to implement a certain type of throttling of events in reactive-banana. It should work such that an event is not let through if arrives at less then delta seconds from the last event that passed through. If it is not let through then it is stored and is fired after delta seconds from the last fired event. Below is a program that implements this for lists of time stamped numbers.
我想对反应性香蕉实施某种类型的事件限制。 它应该起作用,以使得如果从最后一次通过的事件到达的时间少于三秒,事件就不会通过。 如果它没有通过,那么它将被存储并在最后一次触发事件的增量秒后触发。 以下是一个实现此功能的程序,用于列出带时间戳的数字。 将它翻译成反应香蕉是否可能? 另外,在反应式香蕉中,如何在某些其他事件进入后x秒钟内发射一个事件? module Main where import Data.List -- 1 second th
In the Repa package, there is a Boundary datatype: data Boundary a = BoundFixed !a | BoundConst !a | BoundClamp deriving (Show) I understand what is meant by BoundConst (cells outside of the array are treated as single value), and I understand what is meant by BoundClamp (cells outside of the array are the same values as the closest array cell). What is meant b
Repa包中有一个Boundary数据类型: data Boundary a = BoundFixed !a | BoundConst !a | BoundClamp deriving (Show) 我明白BoundConst是什么意思(数组之外的单元格被视为单个值),并且我明白BoundClamp (数组之外的单元格与最接近的数组单元格的值相同)。 BoundFixed是什么意思? 描述是使用边界区域的固定值。 什么是“边境地区”? 这些都是边缘细胞吗? 通过读取mapStencil2和pa
The following code produces the (dreaded) "nested parallelism" error with repa-3.4.0.1: import Control.Monad.Identity (runIdentity, liftM) import Data.Array.Repa as R import Data.Array.Repa.Repr.Unboxed import Data.Vector.Unboxed import Test.Framework import Test.Framework.Providers.QuickCheck2 import Test.QuickCheck hiding (generate,output) main :: IO () main = defaultMa
以下代码在repa-3.4.0.1中产生(可怕的)“嵌套并行性”错误: import Control.Monad.Identity (runIdentity, liftM) import Data.Array.Repa as R import Data.Array.Repa.Repr.Unboxed import Data.Vector.Unboxed import Test.Framework import Test.Framework.Providers.QuickCheck2 import Test.QuickCheck hiding (generate,output) main :: IO () main = defaultMainWithArgs [prop,prop] ["--maximum-genera
In Repa, I would like to apply a certain d -dimensional linear transform in parallel across the innermost dimension of my array, ie, on all "column" vectors. In general, such a transform can be expressed as a matrix M , and each entry of M*v is just a dot product of the appropriate row of M with v . So I could just use traverse with a function that computes the appropriate dot produc
在Repa中,我想要在我的数组的最内维上并行应用某个d维线性变换,即在所有“列”向量上。 通常,这样的变换可以表示为矩阵M ,并且M*v每个条目只是M的适当行与v的点积。 所以,我可以只使用traverse与计算相应的点积的功能。 这花费d^2工作。 但是,我的M是特殊的:它承认线性工作顺序算法。 例如, M可能是整个下三角形中1 s的下三角矩阵。 那么M*v只是v (即“扫描”)的部分和的向量。 这些总和可以以明显的方式顺序计算
I'm writing code to do a subset product: it takes a list of elements and a list of indicator variables (of the same length). The product is computed in a tree, which is crucial to our application. Each product is expensive, so my goal was to compute each level of the tree in parallel, evaluating consecutive levels in sequence. Thus there isn't any nested parallelism going on. I only
我正在编写代码来完成子集产品:它需要一个元素列表和一个指示器变量列表(长度相同)。 该产品在树中计算,这对我们的应用至关重要。 每个产品都很昂贵,所以我的目标是并行计算树的每个级别,按顺序评估连续级别。 因此没有任何嵌套的并行操作正在进行。 我只有一个函数中的代码,接近我的整个代码的顶层。 请注意subsetProd不是一元的。 步骤: 把这些列表组合成一对(无并行) 压缩分块列表(无并行) 将产品
Does anyone know how I can print λ instead of using haskell in emacs. I know that one can use haskell-font-lock-symbols, but I find the rest of them hard to read - the arrows are TOO small! Is there a simple way of over-riding the rest of the keys? You can do this: (defun pretty-lambdas-haskell () (font-lock-add-keywords nil `((,(concat "\(" (regexp-quote "\") "\)") (0 (prog
有谁知道我如何在emacs中使用haskell打印λ而不是。 我知道可以使用haskell-font-lock-symbols,但是我发现其余的很难阅读 - 箭头太小了! 有没有一种简单的方法可以覆盖其余的键? 你可以这样做: (defun pretty-lambdas-haskell () (font-lock-add-keywords nil `((,(concat "\(" (regexp-quote "\") "\)") (0 (progn (compose-region (match-beginning 1) (match-end 1)
This question is about how to design an app, and layout data, to represent mutable state in an adventure game where there are locations the player can be in, and items which can either be in those locations, or in the players inventory after they pick them up. newtype ItemName = ItemName Text newtype LocationName = LocationName Text newtype Description = Description Text new type ItemWeight
这个问题是关于如何设计一个应用程序和布局数据,以在冒险游戏中表示可变状态,其中存在玩家可以进入的位置以及可以在这些位置或者在他们选择之后在玩家库存中的物品他们了。 newtype ItemName = ItemName Text newtype LocationName = LocationName Text newtype Description = Description Text new type ItemWeight = ItemWeight Int data Location = Location LocationName Description [Item] data Item = Item