aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--README.md31
-rw-r--r--compile.c6
-rw-r--r--iclean.icl9
4 files changed, 40 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 83ba767..8e2d6b5 100644
--- a/Makefile
+++ b/Makefile
@@ -10,5 +10,5 @@ iclean: compile.o iclean.icl
clm -l compile.o iclean -o iclean
run: iclean
- ./iclean
+ ./iclean -nr -nt
diff --git a/README.md b/README.md
index 052d209..b874492 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,33 @@
# iClean
Interactive Clean
+
+This module allows you to execute Clean commands interactively, similar to GHCi or the Python shell. Functionality is very limited. In particular there is **no memory**, so you're restricted to one-liners.
+
+## Example session
+
+ $ ./iclean
+ > [1,2,3,4]
+ [1,2,3,4]
+ > map toString [1..10]
+ ["1","2","3","4","5","6","7","8","9","10"]
+ > [Ctrl-D]
+ $
+
+## Installation
+
+ make iclean
+
+## Running
+Either
+
+ ./iclean
+
+or
+
+ make run
+
+## Todo
+
+ * Implement memory (e.g. to first declare a function / constant and then use it)
+ * Commands memory (scroll through previous commands with arrow keys)
+ * Imports
diff --git a/compile.c b/compile.c
index 3b92ed2..2295f20 100644
--- a/compile.c
+++ b/compile.c
@@ -42,7 +42,7 @@
*
* @return void
*/
-void compile(CleanString path, CleanString module) {
+int64_t compile(CleanString path, CleanString module) {
char* pathchars, * modulechars;
int pathlength, modulelength;
@@ -71,13 +71,13 @@ void compile(CleanString path, CleanString module) {
// Build command:
// clm -ms <module> -o <module>
- char cmd[64] = "clm -ms ";
+ char cmd[64] = "clm -ms -nw ";
strcat(cmd, modulechars);
strcat(cmd, " -o ");
strcat(cmd, modulechars);
// Call clm
- system(cmd);
+ return system(cmd);
}
/**
diff --git a/iclean.icl b/iclean.icl
index a5ca38c..e17cb86 100644
--- a/iclean.icl
+++ b/iclean.icl
@@ -43,11 +43,12 @@ Start w
where
loop :: *World -> *World
loop w
- #! w = print "> " w
+ #! w = print "λ. " w
#! (s,w) = readline w
| s == "" = w
#! w = writemodule s w
- #! w = compile temp_path temp_module w
+ #! (r,w) = compile temp_path temp_module w
+ | r <> 0 = loop w
#! w = run (temp_path +++ temp_module) w
= loop w
@@ -81,9 +82,9 @@ writemodule s w
| not ok = abort ("Couldn't close " +++ temp_file +++ "\n")
| otherwise = w
-compile :: !String !String *World -> *World
+compile :: !String !String !*World -> !*(!Int,!*World)
compile _ _ _ = code {
- ccall compile "SS:V:p"
+ ccall compile "SS:p:p"
}
run :: !String *World -> *World