elixirst

Session Types in Elixir

https://github.com/gertab/elixirst

Science Score: 57.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 8 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.1%) to scientific vocabulary

Keywords

concurrency elixir session-types
Last synced: 6 months ago · JSON representation ·

Repository

Session Types in Elixir

Basic Info
  • Host: GitHub
  • Owner: gertab
  • License: gpl-3.0
  • Language: Elixir
  • Default Branch: master
  • Homepage:
  • Size: 3.2 MB
Statistics
  • Stars: 49
  • Watchers: 5
  • Forks: 2
  • Open Issues: 0
  • Releases: 0
Topics
concurrency elixir session-types
Created about 5 years ago · Last pushed over 2 years ago
Metadata Files
Readme Citation

README.md

Elixir CI

ElixirST (Session Types in Elixir) applies session types to a fragment of the Elixir language. It statically checks that the programs use the correct communication structures (e.g. send/receive) when dealing with message passing between processes. <!-- It also ensures that the correct types are being used. --> <!-- For example, the session type ?Add(number, number).!Result(number).end expects that two numbers are received (i.e. ?), then a number is sent (i.e. !) and finally the session terminates. -->

The design decisions of ElixirST and its underlying theory are described in the following papers co-authored by Gerard Tabone and Adrian Francalanza: - ElixirST: A Session-Based Type System for Elixir Modules. JLAMP 2023. (doi, pdf) - Session Fidelity for ElixirST: A Session-Based Type System for Elixir Modules. ICE 2022. (doi, pdf) - Session Types in Elixir. AGERE 2021. (doi, pdf) - Static Checking of Concurrent Programs in Elixir Using Session Types. Technical report, 2022. (pdf)

Example

To session typecheck modules in Elixir, add use ElixirST and include any assertions using the annotations @session and @dual preceding any public function (def). The following is a simple example, which receives one label (?Hello()): <!-- The @spec directives are needed to ensure type correctness for the parameters. -->

```elixir defmodule Example do use ElixirST

@session "server = ?Hello().end" @spec server(pid) :: atom() def server(_pid) do receive do {:Hello} -> :ok end end

@dual "server" @spec client(pid) :: {atom()} def client(pid) do send(pid, {:Hello}) end end ```

ElixirST runs automatically at compile time (mix compile) or as a mix task (mix sessions [module name]): text $ mix sessions SmallExample [info] Session typechecking for client/1 terminated successfully [info] Session typechecking for server/0 terminated successfully

If the client sends a different label (e.g. :Hi) instead of the one specified in the session type (i.e. @session "!Hello()"), ElixirST will complain:

text $ mix sessions SmallExample [error] Session typechecking for client/1 found an error. [error] [Line 7] Expected send with label :Hello but found :Hi.

Session Types in Elixir

Session types are used to ensure correct communication between concurrent processes. The session type operations include the following: ! refers to a send action, ? refers to a receive action, & refers to a branch (external choice), and + refers to an (internal) choice.

Session types accept the following grammar:

```text S = !label(types, ...).S (send) | ?label(types, ...).S (receive) | &{?label(types, ...).S, ...} (branch) | +{!label(types, ...).S, ...} (choice) | rec X.(S) (recurse) | X (recursion var) | end (terminate)

types = atom | boolean | number | atom | pid | {types, types, ...} (tuple) | types ```


Using ElixirST

Installation

The package can be installed by adding elixirst to your list of dependencies in mix.exs:

elixir def deps do [ {:elixirst, "~> 0.8.3"} ] end <!-- elixir def deps do [ {:dep_from_git, git: "https://github.com/gertab/ElixirST.git"} ] end

{:depfromgit, git: "https://github.com/gertab/ElixirST.git", tag: "0.1.0"} -->

Documentation can be found at https://hexdocs.pm/elixirst.

Use in Elixir modules

To session typecheck a module, link the ElixirST library using this line: elixir use ElixirST

Insert any checks using the @session attribute followed by a function that should be session typechecked, such as: elixir @session "pinger = !Ping().?Pong()" def function(), do: ...

The @dual attribute checks the dual of the specified session type. ```elixir @dual "pinger"

Equivalent to: @session "?Ping().!Pong()"

```

Other examples can be found in the examples folder.

Cite

Feel free to cite ElixirST as follows (or use .bib file):

Francalanza, A., & Tabone, G. (2023). ElixirST: A session-based type system for Elixir modules. Journal of Logical and Algebraic Methods in Programming, 135, 100891. https://doi.org/10.1016/j.jlamp.2023.100891

Acknowledgements

Some code related to Elixir expression typing was adapted from typelixir by Cassola (MIT licence).

This project is licenced under the GPL-3.0 licence.

Owner

  • Name: Gerard Tabone
  • Login: gertab
  • Kind: user
  • Location: Malta

Citation (citation.cff)

cff-version: 1.2.0
message: "Feel free to cite it as below."
authors:
  - family-names: Francalanza
    given-names: Adrian
    orcid: https://orcid.org/0000-0003-3829-7391
  - family-names: Tabone
    given-names: Gerard
    orcid: https://orcid.org/0000-0001-9047-061X
title: "ElixirST"
version: 0.8.3
date-released: 2021-09-17
url: "https://github.com/gertab/ElixirST"
keywords:
  - "Session types"
  - "Type systems"
  - "Elixir"
  - "Functional programming"
license: "GPL-3.0"
preferred-citation:
  type: article
  authors:
  - family-names: Francalanza
    given-names: Adrian
    orcid: https://orcid.org/0000-0003-3829-7391
  - family-names: Tabone
    given-names: Gerard
    orcid: https://orcid.org/0000-0001-9047-061X
  doi: 10.1016/j.jlamp.2023.100891
  journal: "Journal of Logical and Algebraic Methods in Programming"
  month: 10
  start: 100891
  title: "ElixirST: A session-based type system for Elixir modules"
  volume: 135
  year: 2023

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 328
  • Total Committers: 3
  • Avg Commits per committer: 109.333
  • Development Distribution Score (DDS): 0.012
Top Committers
Name Email Commits
Gerard g****e@y****m 324
Gerard Tabone g****b@u****m 3
Kian-Meng Ang k****g@c****g 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: 5 days
  • Total issue authors: 0
  • Total pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.5
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • kianmeng (1)
  • gertab (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • hex 1,717 total
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 16
  • Total maintainers: 1
hex.pm: elixirst

ElixirST: Session Types in Elixir

  • Versions: 16
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 1,717 Total
Rankings
Stargazers count: 13.4%
Dependent repos count: 18.7%
Dependent packages count: 21.8%
Forks count: 26.1%
Average: 27.7%
Downloads: 58.4%
Maintainers (1)
Last synced: 6 months ago

Dependencies

mix.exs hex
  • dialyxir ~> 1.0
  • ex_doc ~> 0.22.0
  • excoveralls ~> 0.10
.github/workflows/elixir.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • erlef/setup-elixir 885971a72ed1f9240973bd92ab57af8c1aa68f24 composite
mix.lock hex