Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update elm implementation, fix keywords and metadata, merge eval #608

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 4 additions & 17 deletions impls/elm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04
FROM ubuntu:20.04
MAINTAINER Joel Martin <[email protected]>

##########################################################
Expand All @@ -9,10 +9,8 @@ MAINTAINER Joel Martin <[email protected]>
RUN apt-get -y update

# Required for running tests
RUN apt-get -y install make python

# Some typical implementation and test requirements
RUN apt-get -y install curl libreadline-dev libedit-dev
RUN apt-get -y install make python3
RUN ln -s /usr/bin/python3 /usr/local/bin/python

RUN mkdir -p /mal
WORKDIR /mal
Expand All @@ -21,18 +19,7 @@ WORKDIR /mal
# Specific implementation requirements
##########################################################

# For building node modules
RUN apt-get -y install g++

# Add nodesource apt repo config for 10.x stable
RUN apt-get -y install gnupg
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -

# Install nodejs
RUN apt-get -y install nodejs

# For pulling elm packages
RUN apt-get -y install netbase
RUN apt-get -y install g++ libreadline-dev npm

ENV HOME /mal
ENV NPM_CONFIG_CACHE /mal/.npm
26 changes: 11 additions & 15 deletions impls/elm/Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
SOURCES = step0_repl.elm step1_read_print.elm step2_eval.elm \
step3_env.elm step4_if_fn_do.elm step5_tco.elm step6_file.elm \
step7_quote.elm step8_macros.elm step9_try.elm stepA_mal.elm
SOURCES = src/Step0_repl.elm src/Step1_read_print.elm src/Step2_eval.elm src/\
Step3_env.elm src/Step4_if_fn_do.elm src/Step5_tco.elm src/Step6_file.elm src/\
Step7_quote.elm src/Step8_macros.elm src/Step9_try.elm src/StepA_mal.elm

BINS = $(SOURCES:%.elm=%.js)
BINS = $(SOURCES:src/Step%.elm=step%.js)

ELM_MAKE = node_modules/.bin/elm-make
ELM_PACKAGE = node_modules/.bin/elm-package
ELM = node_modules/.bin/elm

all: node_modules elm_packages $(BINS)
all: node_modules $(BINS)

node_modules:
npm install

elm_packages:
$(ELM_PACKAGE) install -y
step%.js: src/Step%.elm node_modules
$(ELM) make $< --output $@

%.js: %.elm node_modules elm_packages
$(ELM_MAKE) $(@:%.js=%.elm) --output $@

STEP0_SOURCES = IO.elm
STEP1_SOURCES = $(STEP0_SOURCES) Reader.elm Printer.elm Utils.elm Types.elm Env.elm
STEP0_SOURCES = src/IO.elm
STEP1_SOURCES = $(STEP0_SOURCES) src/Reader.elm src/Printer.elm src/Utils.elm src/Types.elm src/Env.elm
STEP2_SOURCES = $(STEP1_SOURCES)
STEP3_SOURCES = $(STEP2_SOURCES)
STEP4_SOURCES = $(STEP3_SOURCES) Core.elm Eval.elm
STEP4_SOURCES = $(STEP3_SOURCES) src/Core.elm src/Eval.elm

step0_repl.js: $(STEP0_SOURCES)
step1_read_print.js: $(STEP1_SOURCES)
Expand Down
201 changes: 0 additions & 201 deletions impls/elm/Reader.elm

This file was deleted.

24 changes: 14 additions & 10 deletions impls/elm/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ var fs = require('fs');
var args = process.argv.slice(2);
var mod = require('./' + args[0]);

var app = mod.Main.worker({
args: args.slice(1)
var app = mod.Elm['S' + args[0].slice(1)].init({
flags: {
args: args.slice(1)
}
});

// Hook up the writeLine and readLine ports of the app.
Expand All @@ -22,11 +24,13 @@ app.ports.readLine.subscribe(function(prompt) {
});

// Read the contents of a file.
app.ports.readFile.subscribe(function(filename) {
try {
var contents = fs.readFileSync(filename, 'utf8');
app.ports.input.send({"tag": "fileRead", "contents": contents});
} catch (e) {
app.ports.input.send({"tag": "exception", "message": e.message});
}
});
if ('readFile' in app.ports) {
app.ports.readFile.subscribe(function(filename) {
try {
var contents = fs.readFileSync(filename, 'utf8');
app.ports.input.send({"tag": "fileRead", "contents": contents});
} catch (e) {
app.ports.input.send({"tag": "exception", "message": e.message});
}
});
}
15 changes: 0 additions & 15 deletions impls/elm/elm-package.json

This file was deleted.

21 changes: 21 additions & 0 deletions impls/elm/elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/core": "1.0.5",
"elm/json": "1.1.3",
"elm/parser": "1.1.0",
"elm/regex": "1.0.0",
"elm/time": "1.0.0"
},
"indirect": {}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
2 changes: 1 addition & 1 deletion impls/elm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ffi-napi": "2.4.x"
},
"devDependencies": {
"elm": "^0.18.0"
"elm": "^0.19.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion impls/elm/run
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
#!/usr/bin/env bash
exec node $(dirname $0)/bootstrap.js ${STEP:-stepA_mal} "${@}"