提问人:Craig 提问时间:10/15/2013 最后编辑:dfeuerCraig 更新时间:12/28/2014 访问量:861
带引用的 Haskell 数据类型
Haskell Data Type With References
问:
我正在实现 Ukkonen 的算法,该算法要求树的所有叶子都包含对同一整数的引用,我正在 Haskell 中这样做以了解有关该语言的更多信息。但是,我很难写出执行此操作的数据类型。
-- Node has children, indexes of info on the edge
-- to it, and an optional suffix link.
-- Leaf has a beginning index of the info, but the
-- end index is always an incrementing variable index.
data STree = Node [STree] (Int, Int) (Maybe STree)
| Leaf (Int, ??? )
如何将引用放在类型声明中?Leaf
答: 暂无答案
评论
Data.IORef
s
runST
runST
data STree s = Node [STree s] (Int, Int) (Maybe (STree s)) | Leaf (Int, STRef s Int)
IORef