def conns.cut

bend-kit-http@0.38.2.0 · http.bend:2721

import bend-kit-http@0.38.2.0/http.bend as Http
import Base

2721# The first n sockets; the rest are closed.
2722def conns.cut(xs: List<&1, Conn>, n: Nat) -> IO(List<&1, Conn>):
2723  match xs:
2724    case Nil{}:
2725      IO.pure(List<&1, Conn>, Nil{})
2726    case Con{c, t}:
2727      match n:
2728        case 0n:
2729          do IO<List<&1, Conn>>:
2730            conn.close(c)
2731            conns.cut(t, 0n)
2732        case 1n+k:
2733          do IO<List<&1, Conn>>:
2734            r : List<&1, Conn> <- conns.cut(t, k)
2735            return c <> r

Uses (8)

Used by (2)