本文介绍了用于Haskell中严格数据结构的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存在哪些实现严格数据结构的库?具体而言,我正在寻找严格的清单和严格的设置。



免责声明:


  1. 我知道深度。这是非常有用的,但是它增加了每次使用deepseq(可能不止一次)遍历整个数据结构的开销。

  2. 我知道一个严格的类似容器的数据结构不会
    确保它所包含的所有内容都被完全评估,但
    本身的结构应该是严格的,例如:

      data StrictList a =!a:$!(StrictList a)|空的

    (这里包含的元素在WHNF中,可能没有完全评估,但是结构例如,无限列表将是非终止值。)

  3. 我知道关于hackage的'strict'包,但它有一个非常
    有限的一套严格的数据结构。它没有包含严格的
    列表和集合。

  4. 编写严格的列表我自己似乎非常容易(我喜欢ghc的
    扩展来派生Functor ,Traversable和Foldable,btw。),但它
    似乎仍然会更好地在单独的库中完成。
    有效的集合实现对我来说似乎并不重要。


解决方案 div>

包(随ghc一起发布)很快就会有严格的Set和Map变体(我不确定它们将被包含在ghc-7.4中,但有理由希望)。因此,严格的Sets和Maps的高效实现即将开始。正如你所说的那样,严格的列表仍然是一个hackage包,提供它们会很好,所以不是每个人都必须自己做。你还需要什么?


What libraries do exist that implement strict data structures? Specifically, I am looking for strict lists and strict sets.

Disclaimers:

  1. I am aware of deepseq. It's very useful, but it adds the overhead of traversing the whole data structure every time you use deepseq (which might be more than once).

  2. I am aware that a strict container-like data structure does notensure everything it contains will be fully evaluated, but the structureitself should be strict, e.g.:

    data StrictList a = !a :$ !(StrictList a) | Empty
    

    (Here, the contained elements are in WHNF, and possibly not fully evaluated, but the structure of the list is. For example, infinite lists will be non-terminating values.)

  3. I know about the 'strict' package on hackage, but it has a verylimited set of strict data structures. It does neither contain strictlists nor sets.

  4. Writing strict lists myself seems amazingly easy (I love ghc'sextensions to derive Functor, Traversable and Foldable, btw.), but itstill seems like it would be better done in a separate library. Andefficient implementations of sets don't seem that trivial to me.

解决方案

The containers package (shipped with ghc) will soon have strict Set and Map variants (I'm not sure they will be included with ghc-7.4, but there's reason to hope). So an efficient implementation of strict Sets and Maps is on the way. Strict lists are, as you say easy, still a package on hackage providing them would be nice, so not everybody has to do it themselves. What else do you need?

这篇关于用于Haskell中严格数据结构的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 09:57