Haskell Data Type With References

会有一股神秘感。 提交于 2019-12-04 21:45:18

问题


I'm implementing Ukkonen's algorithm, which requires that all leaves of a tree contain a reference to the same integer, and I'm doing it in Haskell to learn more about the language. However, I'm having a hard time writing out a data type that does this.

-- 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, ??? )

How can I put the reference in the Leaf type declaration?

来源:https://stackoverflow.com/questions/19370296/haskell-data-type-with-references

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!