gleam/io
Types
Error value returned by get_line
function
pub type GetLineError {
Eof
NoData
}
Constructors
-
Eof
-
NoData
Functions
pub fn debug(term: a) -> a
Prints a value to standard output using Erlang syntax.
The value is returned after being printed so it can be used in pipelines.
Example
> io.debug("Hi mum")
// -> <<"Hi mum">>
"Hi mum"
> io.debug(Ok(1))
// -> {ok, 1}
Ok(1)
> import list
> [1, 2]
> |> list.map(fn(x) { x + 1 })
> |> io.debug
> |> list.map(fn(x) { x * 2 })
// -> [2, 3]
[4, 6]
pub external fn get_line(
prompt: String,
) -> Result(String, GetLineError)
Reads a line from standard input with the given prompt.
Example
> io.get_line("Language: ")
// -> Language: <- gleam
Ok("gleam\n")
pub fn print(string: String) -> Nil
Writes a string to standard output.
Example
> io.print("Hi mum")
// -> Hi mum
Nil