takeInterval yields nothing, dropInterval drops nothing

Abierto Apto para principiantes
#3,271 0 comentarios 0 reacciones 0 asignados Ver en GitHub

@GuillaumedeVolpiano ya está trabajando en esto.

Desde el 20/11/2026.

  • #3272 de @GuillaumedeVolpiano — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
haskell
Área
backend

Línea de trabajo

Lee src/Streamly/Internal/Data/Stream/Time.hs y compara las definiciones de takeInterval y dropInterval con la reproducción del issue. Ejecuta los dos ejemplos mostrados de Stream.toList y confirma que, después de la corrección, los resultados coinciden con las listas esperadas.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).

Lenguaje dominante
Haskell
Estrellas
926
Forks
71
Merge medio
6 h 49 min
PR fusionados (30 d)
3

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de composewell/streamly

Todos los issues de composewell/streamly

Issues similares

Más issues de Haskell

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.