ck/io▲toc

Input/Output

A sample code of stream:

import ck/io

fun main()
  read-stdin().stream
    val a = sint().unjust
    val b = sint().unjust
    val c = sint().unjust
    val s = sstring()
    (a + b + c).print
    " ".print
    s.println
import ck/io

fun main()
  read-stdinck/io/read-stdin: () -> <exn,fsys> string().stream
    val a = sintck/io/sint: () -> <div,stream> maybe<int>().unjuststd/core/unjust: forall<a> (m : maybe<a>) -> exn a
    val b = sintck/io/sint: () -> <div,stream> maybe<int>().unjuststd/core/unjust: forall<a> (m : maybe<a>) -> exn a
    val c = sintck/io/sint: () -> <div,stream> maybe<int>().unjuststd/core/unjust: forall<a> (m : maybe<a>) -> exn a
    val s = sstringck/io/sstring: () -> stream string()
    (a + b + c).print
    " ".print
    s.println

.

effect streamck/io/stream: HX1

Reasonably fast stream.

fun parse-ints( s : stringstd/core/types/string: V ) : exnstd/core/exn: HX liststd/core/list: V -> V<intstd/core/types/int: V>

Parse integers separated by whitespaces.

fun println( l : liststd/core/list: V -> V<intstd/core/types/int: V>, sep : ?stringstd/core/types/string: V ) : consolestd/core/console: X types/()
fun read-ints(): <consolestd/core/console: X,exnstd/core/exn: HX> liststd/core/list: V -> V<intstd/core/types/int: V>

Read integers from standard input. Warning: if a line to be read contains more than 1,022 characters, this function does not work properly. Use read-stdinck/io/read-stdin: () -> <exn,fsys> string and parse-intsck/io/parse-ints: (s : string) -> exn list<int> instead.

fun read-stdin(): <exnstd/core/exn: HX,fsysstd/core/fsys: X> stringstd/core/types/string: V
fun read-until( p : (charstd/core/types/char: V) -> boolstd/core/types/bool: V ) : streamck/io/stream: HX1 stringstd/core/types/string: V

call read-untilck/io/read-until: (p : (char) -> bool) -> stream string operation of the streamck/io/stream: HX1 effect.

fun sint(): <divstd/core/types/div: X,streamck/io/stream: HX1> maybestd/core/types/maybe: V -> V<intstd/core/types/int: V>

Read an integer from a stream.

fun skip-until( p : (charstd/core/types/char: V) -> boolstd/core/types/bool: V ) : streamck/io/stream: HX1 types/()

call skip-untilck/io/skip-until: (p : (char) -> bool) -> stream () operation of the streamck/io/stream: HX1 effect.

fun skip-whitespaces(): streamck/io/stream: HX1 types/()
fun sstring(): streamck/io/stream: HX1 stringstd/core/types/string: V

Read a string from a stream. This function first skips whitespaces, and then reads characters until reaching whitespace.

private import std/core/typesstd/core/types, std/core/hndstd/core/hnd, std/corestd/core, std/os/pathstd/os/path, std/os/filestd/os/file, std/os/readlinestd/os/readline