aboutsummaryrefslogtreecommitdiff
path: root/src/lux/reader.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/lux/reader.clj')
-rw-r--r--src/lux/reader.clj10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lux/reader.clj b/src/lux/reader.clj
index 571a6c5dc..b81b7c826 100644
--- a/src/lux/reader.clj
+++ b/src/lux/reader.clj
@@ -129,3 +129,13 @@
(reduce (fn [tail head] (&/$Cons head tail))
&/$Nil
(reverse indexed-lines))))
+
+(defn with-source [name content body]
+ (fn [state]
+ (|let [old-source (&/get$ &/$source state)]
+ (|case (body (&/set$ &/$source (from name content) state))
+ (&/$Left error)
+ (&/$Left error)
+
+ (&/$Right state* output)
+ (&/$Right (&/T [(&/set$ &/$source old-source state*) output]))))))