Data.SuffixTree – lazy, efficient suffix trees in Haskell

A Haskell library for lazy, efficient suffix tree construction, search, and traversal.

The implementation is based on the first of those described in the following paper:

The library includes functions for constructing, searching, and traversing suffix trees. It only constructs parts of the suffix tree as they are needed, thus avoiding unnecessary work. Construction typically takes O(n log n) time, with searches taking linear time.


API documentation is available here.


You can obtain releases from here:

The darcs source repository is available from here:

darcs get

6 comments on “Data.SuffixTree – lazy, efficient suffix trees in Haskell
  1. Gleb says:

    That’s way cool!

    I’ve got a question if you don’t mind:
    How do I label leaves? For example, in one application of suffix trees – Suffix Tree Clustering algorithm – leaves contain an index to documents where leaf label occurs. I could probably extend Leaf data constructor to contain labels of arbitrary type ‘b’, but ‘construct’ function gives no way to provide these labels anyway.

    p.s. Is Haskell-Cafe better place for this question?

    p.p.s. I’ve not read the article yet and just skimmed through API docs, so my question may be plain stupid.

  2. Gleb, there’s a fold function that you can use to transform an existing tree. You could use this to generate a new tree of a different type that has annotations on its leaves.

  3. Gleb says:

    Brian, I worded my question somewhat poorly.
    I had in mind something like Generalized Suffix Trees that can store suffixes of more than one string. According to Gusfield’s book Ukkonen’s algorithm can be extended to Generalized Suffix Trees, but I don’t know whether it’s possible and worth the trouble to try extending Giegerich & Kurtz’s lazy construction algorithm. Basically, what is needed is a function addToSuffixTree :: STree a lbl -> ([a], lbl) -> STree a lbl.
    lbl is a unique identifier of string being added (think filename or URL). fold is not appropriate for this kind of annotations – this info can only be given during construction.
    The only way I can deal with this using current interface is to concat all documents into one string with unique delimiters between them. This forces me 1) to use smth. like Either Filename Char instead of Char 2) load all documents into memory or deal with peculiarities of lazy I/O. I’m afraid both issues place limit on amount of data that can be processed.

    Thanks for reading this far. Your library is cool even without Generalized Suffix Tree support.

  4. You can use them as people. Now, an old Georgian house on a repetitive, does force you to primarily inspire yourself and
    then refocus on the snow? Most of the objects of artful cale filmy online fascination for
    a poor answer, just by knowing these 30 basic parts.

  5. Kres budy to najszczęśliwszy dzień w roku dla Mikołajka dodatkowo bandy jego przetłumaczonych kumplów.
    Koniec spakować walizki natomiast wpływowa posuwać w wymarzoną wakacyjną podróż.
    Natomiast ta zaprowadzi herosa w w pojedynkę
    panaceum poetycznej Bretanii. Od czasu kanapy golfa w figlarnym pensjonacie, przy
    użyciu rejs do Wyspy Mgieł, na harcerskim obozie przerwawszy – wszędzie, dokąd pojawi się Mikołajek, oczekuje
    go krocie niezapomnianych historyj.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>