Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions IMPLS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ IMPL:
- {IMPL: fennel}
- {IMPL: forth}
- {IMPL: fsharp}
- {IMPL: gleam, gleam_MODE: erlang}
- {IMPL: gleam, gleam_MODE: js, NO_PERF: 1, NO_SELF_HOST_PERF: 1} # stack overflow
- {IMPL: go}
- {IMPL: groovy}
- {IMPL: gnu-smalltalk}
Expand Down
4 changes: 3 additions & 1 deletion Makefile.impls
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ wasm_MODE = wasmtime
#

IMPLS = ada ada.2 awk bash basic bbc-basic c c.2 chuck clojure coffee common-lisp cpp crystal cs d dart \
elisp elixir elm erlang es6 factor fantom fennel forth fsharp go groovy gnu-smalltalk \
elisp elixir elm erlang es6 factor fantom fennel forth fsharp gleam go groovy gnu-smalltalk \
guile hare haskell haxe hy io janet java java-truffle js jq julia kotlin latex3 livescript logo lua make mal \
matlab miniMAL nasm nim objc objpascal ocaml perl perl6 php picolisp pike plpgsql \
plsql powershell prolog ps purs python2 python3 r racket rexx rpython ruby ruby.2 rust scala scheme skew sml \
Expand All @@ -51,6 +51,7 @@ step5_EXCLUDES += powershell # too slow for 10,000
step5_EXCLUDES += prolog # no iteration (but interpreter does TCO implicitly)
step5_EXCLUDES += sml # not implemented :(
step5_EXCLUDES += $(if $(filter cpp,$(haxe_MODE)),haxe,) # cpp finishes 10,000, segfaults at 100,000
step5_EXCLUDES += $(if $(filter js,$(gleam_MODE)),gleam,)
step5_EXCLUDES += xslt # iteration cannot be expressed
step5_EXCLUDES += vbs # too slow for 10,000

Expand Down Expand Up @@ -133,6 +134,7 @@ fantom_STEP_TO_PROG = impls/fantom/lib/fan/$($(1)).pod
fennel_STEP_TO_PROG = impls/fennel/$($(1)).fnl
forth_STEP_TO_PROG = impls/forth/$($(1)).fs
fsharp_STEP_TO_PROG = impls/fsharp/$($(1)).exe
gleam_STEP_TO_PROG = impls/gleam/$($(1))
go_STEP_TO_PROG = impls/go/$($(1))
groovy_STEP_TO_PROG = impls/groovy/$($(1)).groovy
gnu-smalltalk_STEP_TO_PROG = impls/gnu-smalltalk/$($(1)).st
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ FAQ](docs/FAQ.md) where I attempt to answer some common questions.
| [Fantom](#fantom) | [Dov Murik](https://github.com/dubek) |
| [Fennel](#fennel) | [sogaiu](https://github.com/sogaiu) |
| [Forth](#forth) | [Chris Houser](https://github.com/chouser) |
| [Gleam](#gleam) | [Dondorio](https://github.com/Dondorio) |
| [GNU Guile](#gnu-guile-21) | [Mu Lei](https://github.com/NalaGinrut) |
| [GNU Smalltalk](#gnu-smalltalk) | [Vasilij Schneidermann](https://github.com/wasamasa) |
| [Go](#go) | [Joel Martin](https://github.com/kanaka) |
Expand Down Expand Up @@ -531,6 +532,15 @@ cd impls/forth
gforth stepX_YYY.fs
```

### Gleam

The Gleam implementation of mal has been tested with Gleam 1.17.0

```
cd impls/gleam
./run
```

### GNU Guile 2.1+

```
Expand Down
5 changes: 5 additions & 0 deletions impls/gleam/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.beam
*.ez
/build
/node_modules
erl_crash.dump
26 changes: 26 additions & 0 deletions impls/gleam/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM alpine:3.24.1
MAINTAINER Dondorio <dondadecahedron@gmail.com>
LABEL org.opencontainers.image.source=https://github.com/kanaka/mal
LABEL org.opencontainers.image.description="mal test container: gleam"

##########################################################
# General requirements for testing or common across many
# implementations
##########################################################

# Required for running tests
RUN apk add --no-cache make python3 bash
RUN ln -fs /usr/bin/python3 /usr/local/bin/python

RUN mkdir -p /mal
WORKDIR /mal

##########################################################
# Specific implementation requirements
##########################################################

RUN apk add --no-cache gleam erlang28 rebar3 nodejs npm
RUN mkdir -p /.cache
RUN chmod -R 777 /.cache
RUN mkdir -p /.npm
RUN chmod -R 777 /.npm
24 changes: 24 additions & 0 deletions impls/gleam/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
STEPS = \
step0_repl \
step1_read_print \
step2_eval \
step3_env \
step4_if_fn_do \
step5_tco \
step6_file \
step7_quote \
step8_macros \
step9_try \
stepA_mal

gleam_MODE ?= erlang

$(STEPS):
ifneq ($(filter $(gleam_MODE), javascript js), )
npm install
endif
gleam build --target $(gleam_MODE)

clean:
gleam clean
rm -rf node_modules
12 changes: 12 additions & 0 deletions impls/gleam/gleam.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name = "mal"
version = "1.0.0"

[dependencies]
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
argv = ">= 1.0.2 and < 2.0.0"
input = ">= 1.0.1 and < 2.0.0"
gleam_regexp = ">= 1.1.1 and < 2.0.0"
gleam_erlang = ">= 1.3.0 and < 2.0.0"
gleam_otp = ">= 1.2.0 and < 2.0.0"
simplifile = ">= 2.4.0 and < 3.0.0"
gleam_time = ">= 1.8.0 and < 2.0.0"
24 changes: 24 additions & 0 deletions impls/gleam/manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file was generated by Gleam
# You typically do not need to edit this file

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
{ name = "gleam_erlang", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "1124AD3AA21143E5AF0FC5CF3D9529F6DB8CA03E43A55711B60B6B7B3874375C" },
{ name = "gleam_otp", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "BA6A294E295E428EC1562DC1C11EA7530DCB981E8359134BEABC8493B7B2258E" },
{ name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
{ name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" },
{ name = "gleam_time", version = "1.8.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_time", source = "hex", outer_checksum = "533D8723774D61AD4998324F5DD1DABDCDBFABAFB9E87CB5D03C6955448FC97D" },
{ name = "input", version = "1.0.1", build_tools = ["gleam"], requirements = [], otp_app = "input", source = "hex", outer_checksum = "FE84CDADC78A1367E4AFD561A529825A8FEC88D165CBDF511FD3226CABCDEE6F" },
{ name = "simplifile", version = "2.4.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "7C18AFA4FED0B4CE1FA5B0B4BAC1FA1744427054EA993565F6F3F82E5453170D" },
]

[requirements]
argv = { version = ">= 1.0.2 and < 2.0.0" }
gleam_erlang = { version = ">= 1.3.0 and < 2.0.0" }
gleam_otp = { version = ">= 1.2.0 and < 2.0.0" }
gleam_regexp = { version = ">= 1.1.1 and < 2.0.0" }
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
gleam_time = { version = ">= 1.8.0 and < 2.0.0" }
input = { version = ">= 1.0.1 and < 2.0.0" }
simplifile = { version = ">= 2.4.0 and < 3.0.0" }
21 changes: 21 additions & 0 deletions impls/gleam/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions impls/gleam/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"readline-sync": "^1.4.10"
}
}
9 changes: 9 additions & 0 deletions impls/gleam/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# Gleam does not let you have uppercase letters in module(file) names
if [ "$STEP" == "stepA_mal" ]; then
STEP=stepa_mal
fi

cd $(dirname $0)
exec gleam run --module ${STEP:-stepa_mal} --no-print-progress --target ${gleam_MODE:-erlang} -- "${@}"
Loading
Loading