From 2f4b63dc80a953da51685a5ed584c89500ed17f1 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 29 Nov 2016 23:45:29 +0100 Subject: Added show_result option --- iclean.icl | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/iclean.icl b/iclean.icl index 4c84509..48dcf35 100644 --- a/iclean.icl +++ b/iclean.icl @@ -62,10 +62,11 @@ help =: instance zero Status where zero = { memory = [], settings = zero } :: Settings - = { show_type :: Bool + = { show_type :: Bool + , show_result :: Bool } -instance zero Settings where zero = { show_type = False } +instance zero Settings where zero = { show_type = False, show_result = True } Start :: *World -> *World Start w @@ -138,6 +139,8 @@ where settings = [ ("show_type", set_bool "Showing types" "Not showing types" (\b s -> {s & settings.show_type = b})) + , ("show_result", set_bool "Showing results" "Not showing results" + (\b s -> {s & settings.show_result = b})) ] lookup :: k [(k,v)] -> Maybe v | == k @@ -171,12 +174,14 @@ writemodule stat s w | not ok = abort ("Couldn't close " +++ temp_file +++ "\n") | otherwise = w where - start - | stat.settings.show_type - = "toString (typeCodeOfDynamic (dynamic start)) " +++ - "+++ \" :: \" +++ foldl (+++) \"\" rslt +++ \"\\n\"\n" - | otherwise - = "foldl (+++) \"\" rslt +++ \"\\n\"\n" + start = case (stat.settings.show_type, stat.settings.show_result) of + (True, True) = type +++ "+++\" :: \"+++" +++ rslt +++ "+++\"\\n\"\n" + (True, False) = type +++ "+++\"\\n\"\n" + (False, True) = rslt +++ "+++\"\\n\"\n" + (False, False) = "()" + where + type = "toString (typeCodeOfDynamic (dynamic start))" + rslt = "foldl (+++) \"\" rslt" // C functions compile :: !String !String !*World -> *(!Int,!*World) -- cgit v1.2.3