title: Working with Data.Sequence in Haskell
body: <p>I wrote a program that turned out to be far too slow using lists so I'm trying to switch over to sequences. However, I can't seem to figure out the correct syntax after looking at the documentation.</p>
  
  <p>So far I'm trying to learn with this simple code:</p>
  
  <pre><code>import Control.Monad
  import qualified Data.Sequence as S
  
  main :: IO ()
  main = do 
         let testSeq = S.empty
         testSeq S.|&gt; 5
         testSeq S.|&gt; 20
         testSeq S.|&gt; 3
         let newSeq = S.update 2 3 testSeq
         let x = lookup 2 testSeq
         print x
  </code></pre>
  
  <p>I've played around with the syntax for a while with no luck but it still has a ton of errors:</p>
  
  <pre><code>test.hs:9:8:
      Couldn't match expected type ‘IO a0’
                  with actual type ‘S.Seq Integer’
      In a stmt of a 'do' block: testSeq S.|&gt; 5
      In the expression:
        do { let testSeq = S.empty;
             testSeq S.|&gt; 5;
             testSeq S.|&gt; 20;
             testSeq S.|&gt; 3;
             .... }
      In an equation for ‘main’:
          main
            = do { let testSeq = ...;
                   testSeq S.|&gt; 5;
                   testSeq S.|&gt; 20;
                   .... }
  
  test.hs:10:8:
      Couldn't match expected type ‘IO a1’
                  with actual type ‘S.Seq Integer’
      In a stmt of a 'do' block: testSeq S.|&gt; 20
      In the expression:
        do { let testSeq = S.empty;
             testSeq S.|&gt; 5;
             testSeq S.|&gt; 20;
             testSeq S.|&gt; 3;
             .... }
      In an equation for ‘main’:
          main
            = do { let testSeq = ...;
                   testSeq S.|&gt; 5;
                   testSeq S.|&gt; 20;
                   .... }
  
  test.hs:11:8:
      Couldn't match expected type ‘IO a2’
                  with actual type ‘S.Seq Integer’
      In a stmt of a 'do' block: testSeq S.|&gt; 3
      In the expression:
        do { let testSeq = S.empty;
             testSeq S.|&gt; 5;
             testSeq S.|&gt; 20;
             testSeq S.|&gt; 3;
             .... }
      In an equation for ‘main’:
          main
            = do { let testSeq = ...;
                   testSeq S.|&gt; 5;
                   testSeq S.|&gt; 20;
                   .... }
  
  test.hs:13:25:
      Couldn't match expected type ‘[(Integer, b)]’
                  with actual type ‘S.Seq a3’
      Relevant bindings include x :: Maybe b (bound at test.hs:13:12)
      In the second argument of ‘lookup’, namely ‘testSeq’
      In the expression: lookup 2 testSeq
  </code></pre>
  
  <p>I'm new to Haskell so any help would be greatly appreciated!</p>