What's really more performant? Haskell or OCaml

I spent the last 18 months getting the grip of functional programming, starting with learning OCaml and for some weeks now Haskell. Now I want to take the next step and implement some actual application: A simple realtime terrain editor. I've written numerous realtime terrain rendering engines, so this is a familiar topic. And the used recursive algorithms and data structures seem very fit

什么更高性能? Haskell或OCaml

我花了18个月的时间来掌握函数式编程,从学习OCaml开始,几个星期后现在Haskell。 现在我想进行下一步并实施一些实际的应用程序:一个简单的实时地形编辑器。 我编写了许多实时地形渲染引擎,所以这是一个熟悉的主题。 所使用的递归算法和数据结构看起来非常适合功能实现。 有了这个实时应用程序,我自然而然地在寻找我可以获得的最佳性能。 现在一些(恕我直言,非常恼人的)OCaml的支持者相对于OCaml或F#而言,对Haskel

core style indexed state monad?

I'm trying to understand indexed monads in the index-core style. I have become stuck in a paradox which is that I can't understand the principles until I have constructed a few examples, and I can't construct examples until I understand the principles. I am trying to construct an indexed state monad. So far my intuition tells me it should be something like this type a :* b = fora

核心风格索引状态monad?

我试图理解索引index-core风格的索引monad。 我陷入了一个悖论,那就是在构建了一些例子之前,我无法理解这些原则,直到我理解了这些原则之后,我才能构建出例子。 我正在尝试构建一个索引状态monad。 到目前为止,我的直觉告诉我应该是这样的 type a :* b = forall i. (a i, b i) newtype IState f a i = IState { runIState :: f i -> (a :* f) } 并且,我可以恢复通过设置“限制”状态单子f = Identity和选择a适当的:

GHC GC'ing sparks

I have a program I'm trying to parallelize (full paste with runnable code here). I've profiled and found that the majority of time is spent in findNearest which is essentially a simple foldr over a large Data.Map . findNearest :: RGB -> M.Map k RGB -> (k, Word32) findNearest rgb m0 = M.foldrWithKey' minDistance (k0, distance rgb r0) m0 where (k0, r0) = M.findMin m0

GHC GC'ing火花

我有一个我试图并行化的程序(在这里完全粘贴可运行代码)。 我异型,发现大部分的时间都花在findNearest这基本上是一个简单的foldr在大Data.Map 。 findNearest :: RGB -> M.Map k RGB -> (k, Word32) findNearest rgb m0 = M.foldrWithKey' minDistance (k0, distance rgb r0) m0 where (k0, r0) = M.findMin m0 minDistance k r x@(_, d1) = -- Euclidean distance in RGB-space

pkg check haddock warnings

Upon a fresh install of the haskell-platform (via homebrew ) ( GHC x64 7.6.3 ) on OSX 10.9.2 I receive the following warnings when I run ghc-pkg check (see below) Warning: haddock-interfaces: /Users/user/.cabal/share/doc/x86_64-osx-ghc-7.6.3/ghc-mod-3.1.7/html/ghc-mod.haddock doesn't exist or isn't a file Warning: haddock-html: /Users/user/.cabal/share/doc/x86_64-osx-ghc-7.6.3/ghc-mod-3.1.7/html

pkg检查黑线鳕警告

在OSX 10.9.2上全新安装haskell-platform(通过homebrew )( GHC x64 7.6.3 )后,运行ghc-pkg check时会收到以下警告(请参见下文) Warning: haddock-interfaces: /Users/user/.cabal/share/doc/x86_64-osx-ghc-7.6.3/ghc-mod-3.1.7/html/ghc-mod.haddock doesn't exist or isn't a file Warning: haddock-html: /Users/user/.cabal/share/doc/x86_64-osx-ghc-7.6.3/ghc-mod-3.1.7/html doesn't exist or isn't a directory W

Kind signatures and Type families

I expect type family Rep a and type family Rep :: * -> * to be the same, but it seems there is a difference type family Rep a type instance Rep Int = Char -- ok type family Rep :: * -> * type instance Rep Int = Char -- Expected kind * -> *, but got 'Int' instead Have I simply stumbled over an Haskell extension bug, or is there some point to this behavior? Yes, there is a s

亲笔签名和类型家庭

我预计 type family Rep a 和 type family Rep :: * -> * 是一样的,但似乎有区别 type family Rep a type instance Rep Int = Char -- ok type family Rep :: * -> * type instance Rep Int = Char -- Expected kind * -> *, but got 'Int' instead 我只是偶然发现了一个Haskell扩展错误,或者是否有一点指向这种行为? 是的,有一个微妙的区别。 粗略地说, type family F a :: *->*表明, F Int

Implicit Arguments and Type Families

I've been experimenting with dependently typed programs using the Data.Singletons library, following the development of length-annotated vectors in the paper, "Dependently Typed Programming with Singletons," and I've run into the following problem. This code, excluding the definition of the function indexI , typechecks in GHC 7.6.3 and works as expected in its absence: {-# LA

隐式参数和类型族

我一直在使用Data.Singletons库试验依赖类型的程序,在文章“使用Singletons进行依赖类型化编程”之后开发了长度注释向量,并且我遇到了以下问题。 该代码(不包括函数indexI的定义)在GHC 7.6.3中进行了类型indexI ,并在缺少时按预期工作: {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperat

overlapping/Incoherent closed type families

I have been playing around a bit with closed type families however I somehow always bump my head at the fact that things usually doesn't work for Num without specifying the type. Here is an example. {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE Undecida

重叠/不连续的封闭类型族

我一直在玩一些封闭类型的家庭,但是我总觉得事物往往不适用于Num而没有指定类型。 这是一个例子。 {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE OverlappingInstances #-} {-# LANGUAGE IncoherentInstances #-} {-

'type family' vs 'data family', in brief?

I'm confused about how to choose between data family and type family . The wiki page on TypeFamilies goes into a lot of detail. Occasionally it informally refers to Haskell's data family as a "type family" in prose, but of course there is also type family in Haskell. There is a simple example that shows where two versions of code are shown, differing only on whether a data f

'type family'vs'data family',简而言之?

我对如何在data family和type family之间进行选择感到困惑。 TypeFamilies上的wiki页面进入了很多细节。 偶尔它会非正式地将Haskell的data family称为散文中的“类型族”,但当然Haskell中也有type family 。 有一个简单的例子,显示了两个版本的代码的显示位置,不同之处仅在于是否声明了data family或type family : -- BAD: f is too ambiguous, due to non-injectivity -- type family F a -- OK data family F a f ::

Type Family Type Hackery

I'm trying to write a fairly polymorphic library. I've run into a situation that's easier to show than tell. It looks a bit like this: {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} import Data.Map (Map) import qualified Data.Map as Map class Format f where type Target f class Format f => Formatter x f where target ::

类型家庭类型的黑客

我试图写一个相当多态的库。 我遇到了一个比告诉更容易展现的情况。 它看起来有点像这样: {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} import Data.Map (Map) import qualified Data.Map as Map class Format f where type Target f class Format f => Formatter x f where target :: forall y. Formatable y => Target f -> x -> y class F

Functional Dependencies / Type Families

With functional dependencies I can constrain type of dependent parameter in a type class using multi-parameter type classes. Just like this: {-# LANGUAGE FunctionalDependencies, MultiParamTypeClasses,TypeSynonymInstances #-} class (Num a, Integral b) => F a b | a -> b where f :: a -> b instance F Int Int where f = id instance F Float Integer where f = truncate And everything

功能依赖/类型系列

通过函数依赖关系,我可以使用多参数类型类来约束类型类中的依赖参数的类型。 像这样: {-# LANGUAGE FunctionalDependencies, MultiParamTypeClasses,TypeSynonymInstances #-} class (Num a, Integral b) => F a b | a -> b where f :: a -> b instance F Int Int where f = id instance F Float Integer where f = truncate 一切都将完美运作。 > f (1 :: Int) 1 > f (1.9 :: Float) 1 但是,