You will use
pooka add slugify(Elixir) andpooka add gleam_stdlib(Gleam)external Name from elixir "Module" { … }external Name from gleam "gleam/string" { … }
The whole program
module main
import pooka/io
/// From Elixir: the `slugify` package.
external Slug from elixir "Slug" {
slugify(text: String) -> String
}
/// From Gleam: the standard library's string functions.
external GleamString from gleam "gleam/string" {
reverse(text: String) -> String
capitalise(text: String) -> String
}
/// A web address for a page title.
slug(title: String) -> String {
Slug.slugify(title)
}
main() {
io.println(slug("A Lantern in the Night Library!"))
io.println(GleamString.capitalise("pooka meets gleam"))
io.println(GleamString.reverse("lantern 🏮"))
}
Run it
Add both packages first; they land in pooka.toml and pooka.lock:
$ pooka add slugify
$ pooka add gleam_stdlib
$ pooka run
a-lantern-in-the-night-library
Pooka meets gleam
🏮 nretnal
How it works
- Elixir modules have capitalised names. Elixir's
Slugis what goes afterfrom elixir. Pooka builds Elixir packages with Mix, so Elixir needs to be installed; if it is not, Pooka says so. - Gleam modules have paths. In Gleam,
gleam/stringis a module path, and that is exactly what goes afterfrom gleam. Gleam packages arrive already compiled to Erlang, so they need nothing extra. - The types line up. Strings are UTF-8 binaries in all three languages, so a Pooka
Stringcrosses into Elixir and Gleam and back without any translation. Gleam'sResultandOptioneven look exactly like Pooka's. - Wrap what you use.
slugis an ordinary Pooka function. The rest of the program calls it and never needs to know which language did the work.
Erlang packages from Hex work the same way: pooka add them and use from erlang, as in Call an Erlang function. The BEAM interop guide shows how each Pooka value looks on the other side.