Custom instances of HStream impossible to write

Abierto
#86 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
haskell
Área
networking

Línea de trabajo

Empieza por HStream, HandleStream, openStream, close y openTCPConnection en Network.TCP; después inspecciona hstreamToConnection y Connection en Network.Stream. Determina una API que permita a las instancias personalizadas de HStream cerrar su HandleStream sin I/O diferida ni depender de la conversión específica de String. Se considera completado cuando un tipo de búfer personalizado puede definir una limpieza explícita de la conexión.

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

Descripción

It would be nice to be able to have an instance of HStream that allows to stream without using lazy I/O; in particular, an instance that would allow us to close the connection when we no longer want the rest of the response body.

However, in order to define a custom type with a corresponding HStream instance one needs to provide, amongst other things, implementations of

openStream :: String -> Int -> IO (HandleStream bufType)
close :: HandleStream bufType -> IO ()

For the implementation of openStream we can use

openTCPConnection :: BufferType ty => String -> Int -> IO (HandleStream ty)

However, for the implementation of close we are stuck; there is no function analogous to openTCPConnection that allows us to close a HandleStream.

Although we have

hstreamToConnection :: HandleStream String -> Connection

and there is a Stream instance for Connection, hstreamToConnection works only for HandleStream String, so that doesn't help either.

Finally, the HandleStream type is completely opaque (it does not even satisfy Functor) so we cannot define a HStream instance for one bufType in terms of the HStream instance for another. If we had some way of defining new instances in terms of old instances (for instance, reuse the instance for lazy bytestrings, but somehow retain a handle to the corresponding HandleStream so that we can close it explicitly) that would be great.

Lenguaje dominante
Haskell
Estrellas
186
Forks
59
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

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 haskell/HTTP

Todos los issues de haskell/HTTP

Issues similares

Más issues de Haskell

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.