The Seq type

  • Building Seqs
  • Seq is Foldable
  • Focusing on the ends
    • Pattern synonyms
    • The other end
  • Working with indices

We get a lot of mileage out of the linked list type [] and its related functions in Data.ListData.List, but there is a whole world of other list-like types out there. The first you should learn about is Seq, because its wide assortment of reasonably efficient operations makes it the most generally useful list type.We will not go into the details of how the Seq data structure is implemented; see Finger Trees (2006) if you are interested in the math.

The Seq type may be found in the Data.SequenceData.Sequence module of the containers package. We will use the following imports:

import Data.Sequence (Seq (..))
import qualified Data.Sequence as Seq

Sign up for access to the full page, plus the complete archive and all the latest content.