-->

Haskell Data Type With References

2019-03-27 21:14发布

问题:

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?