aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/gleam/io.gleam17
2 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27860db..8ed8c3b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## Unreleased
+- Created the `io` module with `print` function.
- The `result` module gains the `nil_error` function.
- The `string` module gains the `trim`, `trim_left`, `trim_right`, `starts_with`,
`ends_with`, `slice`, `pad_left` and `pad_right` functions.
diff --git a/src/gleam/io.gleam b/src/gleam/io.gleam
new file mode 100644
index 0000000..b7f1691
--- /dev/null
+++ b/src/gleam/io.gleam
@@ -0,0 +1,17 @@
+external type DoNotLeak
+
+external fn erl_print(String) -> DoNotLeak =
+ "io" "fwrite"
+
+/// Writes string to standard output
+///
+/// ## Example
+///
+/// > io.print("Hi mum")
+/// Nil
+/// //=> Hi mum
+///
+pub fn print(string: String) -> Nil {
+ erl_print(string)
+ Nil
+} \ No newline at end of file