-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add PureScript implementation #581
Conversation
Is there anything else I need to do? |
Overall, the code itself looks good. One issue I noticed is that step2 uses Env which is part of step3. Can you adjust step2 to not use the Env module? The build doesn't work out of the box. The Makefile doesn't quite work and is missing some dependencies on source files (to trigger rebuild when sources change) and on the npm dependency. Also, the Makefile needs a clean target. I suggest the following changes to the Dockerfile and Makefile: diff --git a/impls/purs/Dockerfile b/impls/purs/Dockerfile
index 935e655b..73f46925 100644
--- a/impls/purs/Dockerfile
+++ b/impls/purs/Dockerfile
@@ -30,8 +30,9 @@ RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
# Install nodejs
RUN apt-get -y install nodejs
-# Install purescript
-RUN apt-get install -y libtinfo5
+# Install purescript and deps
+RUN apt-get install -y git libtinfo5
RUN npm install -g --unsafe-perm purescript spago
-ENV NPM_CONFIG_CACHE /mal/.npm
\ No newline at end of file
+ENV NPM_CONFIG_CACHE /mal/.npm
+ENV HOME /mal
diff --git a/impls/purs/Makefile b/impls/purs/Makefile
index b97196b7..2488a981 100644
--- a/impls/purs/Makefile
+++ b/impls/purs/Makefile
@@ -1,6 +1,8 @@
-src/step%:
- spago bundle-app --main ${${@F}} --to $(@F:%.purs=%.js)
+step%.js: src/step%.purs $(OTHER_SRCS) node_modules/readline-sync
+ spago bundle-app --main $($(<:src/%=%)) --to $@
+node_modules/readline-sync:
+ npm install
#####################
@@ -14,4 +16,10 @@ step6_file.purs = Mal.Step6
step7_quote.purs = Mal.Step7
step8_macros.purs = Mal.Step8
step9_try.purs = Mal.Step9
-stepA_mal.purs = Mal.StepA
\ No newline at end of file
+stepA_mal.purs = Mal.StepA
+
+OTHER_SRCS = src/Readline.js src/Readline.purs src/Types.purs src/Reader.purs \
+ src/Printer.purs src/Env.purs src/Core.purs
+
+clean:
+ rm -rf step*.js output/* You can test that everything works for the build and CI like this:
|
A couple other things:
With those changes (and the Env change I already mentioned), and assuming CI passes, it should be ready to merge. |
Fixed README, Dockerfile, Makefile and step2. |
There was a minor conflict with upstream in the README.md for the counts update. I've fixed that. I forgot one more thing that needs to be done which is to add purs to the IMPLS.yml so that it gets tested by CI (Actions). |
Added to IMPLS.yml. |
The performance test is failing because the I also noticed a couple of other issues while tracking that down:
diff --git a/impls/purs/Makefile b/impls/purs/Makefile
index 6e44cd4c..18e9991d 100644
--- a/impls/purs/Makefile
+++ b/impls/purs/Makefile
@@ -1,4 +1,10 @@
-step%.js: src/step%.purs $(OTHER_SRCS) node_modules/readline-sync
+BINS = step0_repl.js step1_read_print.js step2_eval.js step3_env.js \
+ step4_if_fn_do.js step5_tco.js step6_file.js step7_quote.js \
+ step8_macros.js step9_try.js stepA_mal.js
+
+all: $(BINS)
+
+$(BINS): %.js: src/%.purs $(OTHER_SRCS) node_modules/readline-sync
spago bundle-app --main $($(<:src/%=%)) --to $@
|
Fixed makefile, time-ms and ctrl-d |
I'm now getting the following error when I try and run the performance test:
|
sorry, there was an omission of confirmation. |
The perf tests still don't work. The
Also, I found another bug in the Makefile. The order of variable definitions is significant in Makefiles and so things weren't rebuilding correctly when dependent sources changes. Here is a suggested patch (to move the OTHER_SRCS variable earlier): diff --git a/impls/purs/Makefile b/impls/purs/Makefile
index 59dbe0f3..4dd0582b 100644
--- a/impls/purs/Makefile
+++ b/impls/purs/Makefile
@@ -2,6 +2,9 @@ BINS = step0_repl.js step1_read_print.js step2_eval.js step3_env.js \
step4_if_fn_do.js step5_tco.js step6_file.js step7_quote.js \
step8_macros.js step9_try.js stepA_mal.js
+OTHER_SRCS = src/Readline.js src/Readline.purs src/Types.purs src/Reader.purs \
+ src/Printer.purs src/Env.purs src/Core.purs
+
all: $(BINS)
$(BINS): %.js: src/%.purs $(OTHER_SRCS) node_modules/readline-sync
@@ -26,9 +29,6 @@ step8_macros.purs = Mal.Step8
step9_try.purs = Mal.Step9
stepA_mal.purs = Mal.StepA
-OTHER_SRCS = src/Readline.js src/Readline.purs src/Types.purs src/Reader.purs \
- src/Printer.purs src/Env.purs src/Core.purs
-
clean:
rm -rf step*.js output/*
\ No newline at end of file
|
3d87b95
to
6fbc2e9
Compare
Thank you for the repeated reviews. Fixed Makefile and time related functions. |
Okay, the perf tests works now. A couple more things before merging:
|
The comparison function also supports MalTime and MalInt operations, eliminating conflicts. |
It's still failing: https://github.com/kanaka/mal/runs/4549501254?check_suite_focus=true#step:4:1342 I would recommend converting the value of time-ms to a regular number/integer rather than coercing for every math operation. If more numerical operations are added in the future, there is less to change if time-ms returns a native number rather than having to add coercion to every numeric function. |
Fixed the comparison function.
I thought about unifying all the numeric types in the implementation to Therefore, it is necessary to perform calculations that combine |
Looks good! I had to do a little manual rebasing and cleanup, but I've merged it. Congrats! Do you have a twitter account? If so, do you want to tweet something about this implementation (and I'll retweet it)? Otherwise, I'll just tweet it directly to announce it. BTW, I notice during the build a bunch of non-fatal warnings that looked like this:
|
Thank you for your kind review. I will check the warning later, and if I can fix it, I will make another PR. |
This is a PureScript implementaion.
Passed all tests.
Dockerfile etc. are not ready yet.