/*---------------------------------------------------------------------------
  Copyright 2020-2021, Microsoft Research, Daan Leijen.

  This is free software; you can redistribute it and/or modify it under the
  terms of the Apache License, Version 2.0. A copy of the License can be
  found in the LICENSE file at the root of this distribution.
---------------------------------------------------------------------------*/


/* Read input from stdin.
*/
module std/os/readlinestd/os/readline

extern import
  c file "readline-inline.c"
  js file "readline-inline.js" 


// Read a line of input synchronously from stdin (using UTF8 encoding).
// Read characters until either a newline is encountered (not included in the result),
// or 1023 characters have been read.
pub fun readlinestd/os/readline/readline: () -> <console,exn> string()result: -> <console,exn> string : <std/core/types/total: Econsolestd/core/console/console: X,exnstd/core/exn/exn: (E, V) -> V> stringstd/core/types/string: V
  match readline-errstd/os/readline/readline-err: () -> <console,exn> error<string>() 
    Errorstd/core/exn/Error: forall<a> (exception : exception) -> error<a>(exnexn: exception)  -> Errorstd/core/exn/Error: forall<a> (exception : exception) -> error<a>(exnexn: exception.prependstd/os/readline/prepend: (exn : exception, pre : string) -> <exn,console> exception("unable to read from stdin"literal: string
count= 25
)).untrystd/core/exn/untry: (err : error<string>) -> <exn,console> string Okstd/core/exn/Ok: forall<a> (result : a) -> error<a>(lineline: string) -> lineline: string
fun prependstd/os/readline/prepend: (exn : exception, pre : string) -> exception( exnexn: exception : exceptionstd/core/exn/exception: V, prepre: string : stringstd/core/types/string: V )result: -> total exception : exceptionstd/core/exn/exception: V Exceptionstd/core/exn/Exception: (message : string, info : exception-info) -> exception(prepre: string ++std/core/types/(++): (x : string, y : string) -> string ": "literal: string
count= 2
++std/core/types/(++): (x : string, y : string) -> string exnexn: exception.messagestd/core/exn/exception/message: (exception : exception) -> string, exnexn: exception.infostd/core/exn/exception/info: (exception : exception) -> exception-info
) extern readline-errstd/os/readline/readline-err: () -> console error<string>() : consolestd/core/console/console: X errorstd/core/exn/error: V -> V<stringstd/core/types/string: V> c "kk_os_read_line_error" js "sync_readline_err"