Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d1a4af2
Start named process API
lpil Feb 12, 2025
136c250
API renovation
lpil Feb 13, 2025
bfa94e2
Changelog, remove node.to_atom
lpil Feb 13, 2025
b871e07
Name testing
lpil Feb 18, 2025
f2a1263
Update versions
lpil Feb 18, 2025
6f6f449
Node send rename
lpil Feb 19, 2025
05eb14b
New start functions
lpil Feb 19, 2025
54d4aea
Document, remove try_call functions
lpil Feb 24, 2025
542d3d3
Document and test names and calling
lpil Feb 24, 2025
b894de3
Name documentation
lpil Feb 26, 2025
8ba6625
Name tests
lpil Feb 26, 2025
57c3eae
some doc changes
bcpeinhardt Feb 26, 2025
6fa5a23
Apply suggestions from code review
lpil Feb 27, 2025
8b48031
Correct changelog
lpil Feb 27, 2025
83b9d17
Document start type
lpil Feb 27, 2025
e6206be
Update README
lpil Feb 28, 2025
607aecd
Remove selecting_record* functions
lpil Mar 4, 2025
a12986b
Remove node.untyped_send
lpil Mar 5, 2025
ca05f87
Improve monitor APIs
lpil Mar 5, 2025
8a620b6
Abnormal uses Dynamic instead of String, Use ExitReason more
sbergen Mar 5, 2025
4ffcf78
Relax abnormal exit
lpil Mar 6, 2025
5ea2e9b
Names have a programmer supplied prefix
lpil Mar 11, 2025
c54cb6e
Panic when sending fails
lpil Mar 11, 2025
d8a8761
Note replacements
lpil Mar 11, 2025
7e96509
Improve call, document
lpil Mar 13, 2025
f113865
Typos
lpil Mar 13, 2025
075cf5a
Remove unused
lpil Mar 23, 2025
963cd12
Rename selector functions
lpil Apr 23, 2025
bc5d237
Update CI
lpil Apr 23, 2025
fb37cf8
select_other
lpil Apr 23, 2025
29997fe
v1.0.0-rc1
lpil Apr 23, 2025
abd3703
Use proc_lib
lpil Apr 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- uses: actions/checkout@v3
- uses: erlef/setup-beam@v1
with:
otp-version: "26.2"
otp-version: "27.0"
rebar3-version: "3"
gleam-version: "1.5.1"
gleam-version: "1.8.0"
- run: gleam test
- run: gleam format --check src test
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
# Changelog

## v1.0.0-rc1 - Unreleased

- In the `gleam/erlang/process` module:
- The `Name` type has been introduced. This type is used to give processes
names, making it easier to pass references around your application, and to
have a new process take over a role from a previous one that has crashed.
- The `new_name` function has been added for creating new names.
- The `named_subject` function has been added for creating a subject for a
given name.
- The `register` function now takes a name rather than an atom.
- The `unregister` function now takes a name rather than an atom.
- The `named` function now takes a name rather than an atom.
- The `try_call` and `try_call_forever` functions have been removed in favour
of `call` and `call_forever`.
- The `CallError` type has been removed.
- The `start` function has been replaced by the `spawn` and `spawn_unlinked`
functions.
- The `subject_owner` function now returns a result as a named subject may not
have any process registered for that name.
- The `selecting_record*` functions have been replaced by the
`selecting_record` function.
- The `ProcessDown` type has been removed.
- The `Down` type has been added.
- The `selecting_monitors` function has been added.
- The `selecting_specific_monitor` function has been added.
- The `deselecting_specific_monitor` function has been added.
- The `selecting_process_down` function has been removed.
- The `deselecting_process_down` function has been removed.
- The `Abnormal` variant of the `ExitReason` type now holds a `Dynamic`.
- In the `gleam/erlang/node` module:
- The `to_atom` function has been removed.
- The `send` function has been removed.
- The `gleam/erlang/reference` module has been created with:
- The `Reference` type.
- The `new` function.
- The `gleam/erlang/application` module was created with:
- The `priv_directory` function, formerly of the `gleam/erlang` module.
- The `StartType` type.
- In the `gleam/erlang/atom` module:
- The `AtomNotLoaded` type has been removed.
- The error type of `from_string` is now `Nil`.
- The `from_string` function has been renamed to `get`.
- The `create_from_string` function has been renamed to `create`.
- The `gleam/erlang` module has been removed.
- The `gleam/erlang/os` module has been removed.

## v0.34.0 - 2025-02-02

- Fixed deprecation warnings with the Gleam standard library v0.53.0 or later.
Expand Down
23 changes: 3 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,17 @@

A library for making use of Erlang specific code!

## Features

- Typed Erlang processes and message sending.
- Erlang binary format (de)serialisation.
- Functions for working with Erlang's charlists.
- Basic distributed Erlang support and working with nodes.
- Reading and writing of environment variables.
- Functions for working with atoms.

## Usage

Add this library to your Gleam project

```shell
gleam add gleam_erlang
gleam add gleam_erlang@1
```

And then use it in your code

```gleam
import gleam/io
import gleam/erlang/process

pub fn main() {
let fun = fn() {
process.spawn(fn() {
io.println("Hello from another process running concurrently!")
}
process.start(fun, True)
})
}
```

Expand Down
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ links = [
{ title = "Website", href = "https://gleam.run" },
{ title = "Sponsor", href = "https://github.com/sponsors/lpil" },
]
gleam = ">= 0.32.0"
gleam = ">= 1.7.0"

[dependencies]
gleam_stdlib = ">= 0.53.0 and < 2.0.0"
Expand Down
224 changes: 0 additions & 224 deletions src/gleam/erlang.gleam

This file was deleted.

37 changes: 37 additions & 0 deletions src/gleam/erlang/application.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//// An Erlang application is a collection of code that can be loaded into the
//// Erlang virtual machine and even started and stopped if they define a
//// start module and supervision tree. Each Gleam package is an Erlang
//// application.

import gleam/erlang/node.{type Node}

/// The Erlang/OTP application `start` callback takes a start-type as an
/// argument, indicating the context in which the application is being started.
pub type StartType {
/// A normal application start.
Normal
/// The application is distributed and started at the current node because of
/// a takeover from Node, either because Erlang's `application:takeover/2`
/// function has been called, or because the current node has higher priority
/// than the previous node.
Takeover(previous: Node)
/// The application is distributed and started at the current node because of
/// a failover from the previous node.
Failover(previous: Node)
}

/// Returns the path of an application's `priv` directory, where extra non-Gleam
/// or Erlang files are typically kept. Each Gleam package is an Erlang
/// application.
///
/// Returns an error if no application was found with the given name.
///
/// # Example
///
/// ```gleam
/// application.priv_directory("my_app")
/// // -> Ok("/some/location/my_app/priv")
/// ```
///
@external(erlang, "gleam_erlang_ffi", "priv_directory")
pub fn priv_directory(name: String) -> Result(String, Nil)
Loading