我的一些代码被最新版本的ghc 7.8.2打破了.
我GeneralizedNewtypeDeriving用来派生Data.Vector.Unbox使用以下内容的实例:
data VoxelPos = VoxelPos
{-# UNPACK #-} !Int
{-# UNPACK #-} !Int
{-# UNPACK #-} !Int
deriving (Show, Eq, Ord)
newtype FacePos = FacePos VoxelPos deriving ( Eq, Hashable, NFData, G.Vector U.Vector, M.MVector U.MVector, U.Unbox)
Run Code Online (Sandbox Code Playgroud)
哪里VoxelPos有手动滚动的实例使用(Int, Int, Int):
newtype instance U.MVector s VoxelPos = MV_VoxelPos (U.MVector s (Int, Int, Int))
newtype instance U.Vector VoxelPos = V_VoxelPos (U.Vector (Int, Int, Int))
instance U.Unbox VoxelPos
instance M.MVector U.MVector VoxelPos where
basicLength …Run Code Online (Sandbox Code Playgroud) 我面临着让我的代码并行运行的问题.它是一个3D Delaunay生成器,使用名为DeWall的分治算法.
主要功能是:
deWall::[SimplexPointer] -> SetSimplexFace -> Box -> StateT DeWallSets IO ([Simplex], [Edge])
deWall p afl box = do
...
...
get >>= recursion box1 box2 p1 p2 sigma edges
...
...
Run Code Online (Sandbox Code Playgroud)
它调用可能会调用dewall函数的"递归"函数.正是在这里出现了平行机会.以下代码显示了顺序解决方案.
recursion::Box -> Box -> [SimplexPointer] -> [SimplexPointer] -> [Simplex] -> [Edge] -> DeWallSets -> StateT DeWallSets IO ([Simplex], [Edge])
recursion box1 box2 p1 p2 sigma edges deWallSet
| null afl1 && null afl2 = return (sigma, edges)
| (null) afl1 = do
(s, e) …Run Code Online (Sandbox Code Playgroud) parallel-processing concurrency haskell functional-programming
我需要在3维中使用查找表.该表本身具有73x73x73(389017)双值.
module Hammer.Texture.Table3D where
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import Data.Vector.Unboxed (Vector)
table3D :: V.Vector (V.Vector (Vector Double))
table3D = V.fromList [table0, table1, ... table72]
table0 = V.fromList $ map U.fromList [
[1.973921e+01, 0.000000e+00, ... 0.000000e+00],
.....
[1.973921e+01, 0.000000e+00, ... 0.000000e+00]]
.....
table72 = V.fromList $ map U.fromList [
[1.973921e+01, 0.000000e+00, ... 0.000000e+00],
.....
[1.973921e+01, 0.000000e+00, ... 0.000000e+00]]
Run Code Online (Sandbox Code Playgroud)
问题是GHC无法处理Vector Double或[Double]的这个大小,GHC编译需要花费很多时间(约2分钟),最后,内存会爆炸.似乎GHC上存在内存泄漏或某些bug,因为它适用于非常大的String([Char]).
有什么解决方案可用于使用GHC创建"大型"查找表(双重类型)?
有没有办法在GHCi中结合使用:main和:trace命令?我需要在需要输入参数的应用程序中跟踪异常.