Skip to content

Commit 0bffbf9

Browse files
committed
Make the queues public
Having the annotated queues available seems perhaps more useful than the sliding window function itself, since it lets users use them for whatever style of sliding they desire.
1 parent 529485d commit 0bffbf9

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Data/AnnotatedQueue.hs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
BangPatterns, UndecidableInstances #-}
33

44
-- | An implementation of Okasaki's implicit queues holding elements of some
5-
-- semigroup. We track the sum of them all.
5+
-- semigroup. We track the sum of them all. This structure is designed to
6+
-- support efficient *sliding window* algorithms for streams.
67
module Data.AnnotatedQueue
78
( Queue
89
, ViewL (..)
@@ -120,16 +121,16 @@ on `m`, for a total of 2 units of work.
120121
121122
In the last case, we have two possibilities, depending on the prefix:
122123
123-
1. The prefix has one element. Then the debit allowance on `m` is 0. We force `m`
124-
(for free). We do 1 unit of unshared work. We create a suspension for the
124+
1. The prefix has one element. Then the debit allowance on `m` is 0. We force
125+
`m` (for free). We do 1 unit of unshared work. We create a suspension for the
125126
recursive call and place 2 debits on it to pay for that. Since the debit
126-
allowance for the suspension only allows 1 debit, we pay one of them off now.
127-
So the amortized cost is 2.
127+
allowance for the result middle only allows 1 debit, we pay one of them off
128+
now. So the amortized cost is 2.
128129
129-
2. The prefix has two elements. Then the debit allowance on `m` is 1. We pay off
130-
that debit and force `m`. We do 1 unit of unshared work. We create a suspension
131-
for the recursive call and place 2 debits on it. This is within the debit allowance
132-
for the result. So the amortized cost is 2.
130+
2. The prefix has two elements. Then the debit allowance on `m` is 1. We pay
131+
off that debit and force `m`. We do 1 unit of unshared work. We create a
132+
suspension for the recursive call and place 2 debits on it. This is within the
133+
debit allowance for the result middle. So the amortized cost is 2.
133134
-}
134135

135136
data ViewL s = EmptyL | ViewL !s (Queue s)

streaming.cabal

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ library
204204
, Streaming.Prelude
205205
, Streaming.Internal
206206
, Data.Functor.Of
207-
other-modules:
208-
Data.AnnotatedQueue
207+
, Data.AnnotatedQueue
209208
build-depends:
210209
base >=4.8 && <5
211210
, mtl >=2.1 && <2.3

0 commit comments

Comments
 (0)