summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/eval.c b/eval.c
index 9c737ff..da49137 100644
--- a/eval.c
+++ b/eval.c
@@ -9,11 +9,12 @@ Rune *errormsg;
typedef Datum (*evalfn)(Datum, Datum);
Datum strand(Datum, Datum);
+Datum monadfun(Datum, Datum);
int bindingstrengths[12][12] = {
/* A F H MO DO AF ( ) { } [ ] */
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F */
+ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A */
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* H */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* MO */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* DO */
@@ -29,7 +30,7 @@ int bindingstrengths[12][12] = {
evalfn evalfns[12][12] = {
/* A F H MO DO AF ( ) { } [ ] */
strand, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F */
+ monadfun, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* H */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* MO */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* DO */
@@ -90,4 +91,15 @@ strand(Datum left, Datum right)
result.tag = ArrayTag;
result.array = fnCatenateFirst(left.array,fnEnclose(right.array));
return result;
+}
+
+Datum
+monadfun(Datum left, Datum right)
+{
+ print("Monadic function application\n");
+ Datum result;
+ result.tag = ArrayTag;
+ /* TODO handle undefined functions here */
+ result.array = monadfunctiondefs[left.code](right.array);
+ return result;
} \ No newline at end of file