From b81f241bd90092f52a47f64f4dc8297cc4f82f56 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 19 May 2017 23:54:16 -0400 Subject: - WIP: Added pattern-matching (case) analysis. --- new-luxc/source/luxc/base.lux | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'new-luxc/source/luxc/base.lux') diff --git a/new-luxc/source/luxc/base.lux b/new-luxc/source/luxc/base.lux index e900edf6c..612ce70d2 100644 --- a/new-luxc/source/luxc/base.lux +++ b/new-luxc/source/luxc/base.lux @@ -3,6 +3,7 @@ (lux (control monad) (data [text "T/" Eq] text/format + [product] ["R" result]) [macro #+ Monad] (type ["TC" check])) @@ -142,12 +143,14 @@ (def: #export (with-cursor cursor action) (All [a] (-> Cursor (Lux a) (Lux a))) - (function [compiler] - (let [old-cursor (get@ #;cursor compiler)] - (case (action (set@ #;cursor cursor compiler)) - (#R;Success [compiler' output]) - (#R;Success [(set@ #;cursor old-cursor compiler') - output]) - - (#R;Error error) - (#R;Error error))))) + (if (T/= "" (product;left cursor)) + action + (function [compiler] + (let [old-cursor (get@ #;cursor compiler)] + (case (action (set@ #;cursor cursor compiler)) + (#R;Success [compiler' output]) + (#R;Success [(set@ #;cursor old-cursor compiler') + output]) + + (#R;Error error) + (#R;Error error)))))) -- cgit v1.2.3