takeInterval yields nothing, dropInterval drops nothing

オープン 初心者向け
#3,271 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@GuillaumedeVolpiano がすでに取り組んでいます。

2026年11月20日 から。

  • #3272 @GuillaumedeVolpiano による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
haskell
領域
backend

調査の方向性

src/Streamly/Internal/Data/Stream/Time.hsを読み、takeIntervalとdropIntervalの定義をissueの再現例と照らし合わせてください。示されている2つのStream.toListの例を実行し、修正後の結果が期待されるリストと一致することを確認してください。

索引モデルが issue の本文から書いたものです。

説明

Package: streamly 0.11.1 (the definitions are unchanged on master as of 2026-11-20)
GHC: 9.12.4, threaded runtime

Reproduction

import qualified Streamly.Data.Stream.Prelude as Stream

main :: IO ()
main = do
  Stream.toList (Stream.takeInterval 1 (Stream.fromList [1 .. 10 :: Int])) >>= print
  Stream.toList (Stream.dropInterval 1 (Stream.fromList [1 .. 10 :: Int])) >>= print

Expected: [1,2,3,4,5,6,7,8,9,10], then [].

Actual: [], then [1,2,3,4,5,6,7,8,9,10].

Cause

In src/Streamly/Internal/Data/Stream/Time.hs:

takeInterval d =
    Stream.catMaybes
        . Stream.takeWhile isNothing
        . interject (return Nothing) d . fmap Just

dropInterval d =
    Stream.catMaybes
        . Stream.dropWhile isNothing
        . interject (return Nothing) d . fmap Just

The elements of the stream are wrapped in Just and the timer ticks are
Nothing. takeWhile isNothing therefore stops at the first element of the
stream, and dropWhile isNothing stops dropping at once. The predicates look
inverted: takeInterval should keep elements while they are Just, and
dropInterval should drop them while they are Just, then drop the tick.

Since intervalsOf and the sampleInterval* functions do not go through these
two, they are not affected (sampleIntervalEnd behaves as documented in my
tests).

主要言語
Haskell
スター
926
フォーク
71
平均マージ
6時間 49分
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

composewell/streamly のほかの issue

composewell/streamly の issue をすべて見る

似ている issue

Haskell の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。