aboutsummaryrefslogtreecommitdiff
path: root/src/foreign.gleam
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2018-10-12 23:17:54 +0000
committerLouis Pilfold <louis@lpil.uk>2018-10-12 23:27:53 +0000
commit0e41165e9ce288a253c78e8d7a5f224cd9489535 (patch)
treea89cf7a4a66bba7a3595b98f3c1eb3b25ca891be /src/foreign.gleam
parent82ff1afa3bcab9d880eb6508e004cd71eb1f4a48 (diff)
downloadgleam_stdlib-0e41165e9ce288a253c78e8d7a5f224cd9489535.tar.gz
gleam_stdlib-0e41165e9ce288a253c78e8d7a5f224cd9489535.zip
Lowercase module names
This change has a few benefits: - Module names will be easier to call from Erlang, Elixir, etc. - We can now import (for example) the `result` module and the `Result` type and not have ambiguity as to which we mean in the code.
Diffstat (limited to 'src/foreign.gleam')
-rw-r--r--src/foreign.gleam24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/foreign.gleam b/src/foreign.gleam
new file mode 100644
index 0000000..e921ea8
--- /dev/null
+++ b/src/foreign.gleam
@@ -0,0 +1,24 @@
+doc """
+Foreign data is data that we don't know the type of yet.
+We likely get data like this from interop with Erlang, or from
+IO with the outside world.
+"""
+pub external type Foreign
+;
+
+doc """
+Convert any Gleam data into Foreign data.
+"""
+pub external fn new(a) => Foreign = 'Gleam.Foreign' 'identity'
+
+doc """
+Unsafely cast any type into any other type.o
+
+This is an escape hatch for the type system that may be useful when wrapping
+native Erlang APIs. It is to be used as a last measure only.
+"""
+pub external fn unsafeCoerce(a) => b = 'Gleam.Foreign' 'identity'
+
+fn identity(x) {
+ x
+}