spec =
  do
    let pl =
          do
            x <- await
            yield x
            yield (x+1)
            x <- await
            yield x
            yield (x+1)
        l = [2, 5, 10, 20, 100]

    it "can be constructed into ProcessA" $
      do
        let
            result = run (construct pl) l
        result `shouldBe` [2, 3, 5, 6]

    it "can be repeatedly constructed into ProcessA" $
      do
        let
            result = run (repeatedly pl) l
        result `shouldBe` [2, 3, 5, 6, 10, 11, 20, 21, 100, 101]

    it "can handle the end with catchP." $
      do
        let
            plCatch =
              do
                x <- await `catchP` (yield 1 >> stop)
                yield x
                y <- (yield 2 >> await >> yield 3 >> await) `catchP` (yield 4 >> return 5)
                yield y
                y <- (await >>= yield >> stop) `catchP` (yield 6 >> return 7)
                yield y
        run (construct plCatch) [] `shouldBe` [1]
        run (construct plCatch) [100] `shouldBe` [100, 2, 4, 5, 6, 7]
        run (construct plCatch) [100, 200] `shouldBe` [100, 2, 3, 4, 5, 6, 7]
        run (construct plCatch) [100, 200, 300] `shouldBe` [100, 2, 3, 300, 6, 7]
        run (construct plCatch) [100, 200, 300, 400] `shouldBe` [100, 2, 3, 300, 400, 6, 7]
spec =
  do
    let pl =
          do
            x <- await
            yield x
            yield (x+1)
            x <- await
            yield x
            yield (x+1)
        l = [2, 5, 10, 20, 100]

    it "can be constructed into ProcessA" $
      do
        let
            result = run (construct pl) l
        result `shouldBe` [2, 3, 5, 6]

    it "can be repeatedly constructed into ProcessA" $
      do
        let
            result = run (repeatedly pl) l
        result `shouldBe` [2, 3, 5, 6, 10, 11, 20, 21, 100, 101]

    it "can handle the end with catchP." $
      do
        let
            plCatch =
              do
                x <- await `catchP` (yield 1 >> stop)
                yield x
                y <- (yield 2 >> await >> yield 3 >> await) `catchP` (yield 4 >> return 5)
                yield y
                y <- (await >>= yield >> stop) `catchP` (yield 6 >> return 7)
                yield y
        run (construct plCatch) [] `shouldBe` [1]
        run (construct plCatch) [100] `shouldBe` [100, 2, 4, 5, 6, 7]
        run (construct plCatch) [100, 200] `shouldBe` [100, 2, 3, 4, 5, 6, 7]
        run (construct plCatch) [100, 200, 300] `shouldBe` [100, 2, 3, 300, 6, 7]
        run (construct plCatch) [100, 200, 300, 400] `shouldBe` [100, 2, 3, 300, 400, 6, 7]
spec =
  do
    let pl =
          do
            x <- await
            yield x
            yield (x+1)
            x <- await
            yield x
            yield (x+1)
        l = [2, 5, 10, 20, 100]

    it "can be constructed into ProcessA" $
      do
        let
            result = run (construct pl) l
        result `shouldBe` [2, 3, 5, 6]

    it "can be repeatedly constructed into ProcessA" $
      do
        let
            result = run (repeatedly pl) l
        result `shouldBe` [2, 3, 5, 6, 10, 11, 20, 21, 100, 101]

    it "can handle the end with catchP." $
      do
        let
            plCatch =
              do
                x <- await `catchP` (yield 1 >> stop)
                yield x
                y <- (yield 2 >> await >> yield 3 >> await) `catchP` (yield 4 >> return 5)
                yield y
                y <- (await >>= yield >> stop) `catchP` (yield 6 >> return 7)
                yield y
        run (construct plCatch) [] `shouldBe` [1]
        run (construct plCatch) [100] `shouldBe` [100, 2, 4, 5, 6, 7]
        run (construct plCatch) [100, 200] `shouldBe` [100, 2, 3, 4, 5, 6, 7]
        run (construct plCatch) [100, 200, 300] `shouldBe` [100, 2, 3, 300, 6, 7]
        run (construct plCatch) [100, 200, 300, 400] `shouldBe` [100, 2, 3, 300, 400, 6, 7]