From 0dcc1707ee94e7ab366b8919b2602e0ad4479203 Mon Sep 17 00:00:00 2001 From: darkf Date: Wed, 23 Oct 2013 15:15:34 -0700 Subject: [PATCH] implement cons on strings --- interp.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/interp.hs b/interp.hs index 1a14602..cfff587 100644 --- a/interp.hs +++ b/interp.hs @@ -199,6 +199,15 @@ patternBindings (IntP n) _ = Nothing patternBindings UnitP UnitV = Just M.empty patternBindings UnitP _ = Nothing +-- cons on strings +patternBindings (ConsP x (ListP [])) (StrV (y:[])) = patternBindings x (StrV [y]) +patternBindings (ConsP xp xsp) (StrV (x:xs)) = + do + xe <- patternBindings xp (StrV [x]) + xse <- patternBindings xsp $ StrV xs + Just $ M.union xe xse + +-- cons on lists patternBindings (ConsP x (ListP [])) (ListV (y:[])) = patternBindings x y patternBindings (ConsP xp xsp) (ListV (x:xs)) = do