aboutsummaryrefslogtreecommitdiff
path: root/src/any.gleam
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2018-10-27 22:41:25 +0000
committerLouis Pilfold <louis@lpil.uk>2018-10-27 22:41:25 +0000
commit06928fccf543143bfacb0569297bef5d8184e58f (patch)
tree4e76aab71d1a37a8b0a4b113c6a01d8a875af119 /src/any.gleam
parent1934b3b4f49bfb849cba1c553b0c1c21a554724a (diff)
downloadgleam_stdlib-06928fccf543143bfacb0569297bef5d8184e58f.tar.gz
gleam_stdlib-06928fccf543143bfacb0569297bef5d8184e58f.zip
Foreign -> Any
Closes https://github.com/lpil/gleam/issues/21
Diffstat (limited to 'src/any.gleam')
-rw-r--r--src/any.gleam24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/any.gleam b/src/any.gleam
new file mode 100644
index 0000000..05a789b
--- /dev/null
+++ b/src/any.gleam
@@ -0,0 +1,24 @@
+doc """
+`Any` 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 Any
+;
+
+doc """
+Convert any Gleam data into `Any` data.
+"""
+pub external fn new(a) -> Any = '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
+}