@@ -524,17 +524,20 @@ data Tuple4' a b c d = Tuple4' !a !b !c !d deriving Show
524524{-# INLINE slidingWindow #-}
525525slidingWindow :: forall m a b. (MonadIO m, Storable a)
526526 => Int -> Fold m (a, Maybe a) b -> Fold m a b
527−slidingWindow n (Fold step1 initial1 extract1)= Fold step initial extract
527+slidingWindow n (Fold step1 initial1 extract1) = Fold step initial extract
528528
529529 where
530530
531531 initial = do
532− r <- initial1
533− (rb, rh) <- liftIO $ new n
534− return $
535− case r of
536− Partial s -> Partial $ Tuple4' rb rh (0 :: Int) s
537− Done b -> Done b
532+ if n <= 0
533+ then error "Window size must be > 0"
534+ else do
535+ r <- initial1
536+ (rb, rh) <- liftIO $ new n
537+ return $
538+ case r of
539+ Partial s -> Partial $ Tuple4' rb rh (0 :: Int) s
540+ Done b -> Done b
538541
539542 step (Tuple4' rb rh i st) a
540543 | i < n = do