make work temporarily
[minfp.git] / main.icl
index 136c0e1..6b181af 100644 (file)
--- a/main.icl
+++ b/main.icl
@@ -32,14 +32,17 @@ opts =
        , Option ['g'] ["gen"]       (NoArg (const MGen))       "Up to and including generation"
        ]
 
+exit :: Int [String] *File *World -> *World
+exit i e f w = snd (fclose (foldr fwrites f e) (setReturnCode i w))
+
 Start :: *World -> *World
 Start w
+       # (io, w) = stdio w
        # ([argv0:args], w) = getCommandLine w
        # (mode, positionals, errs) = getOpt Permute opts args
        # mode = foldl (o) id mode MInterpret
-//     | not (errs =: []) = Left [e +++ "\n"\\e<-errs]
-//     | not (positionals =: []) = die ["Positional arguments not allowed"] w
-       # (io, w) = stdio w
+       | not (errs =: []) = exit 1 [e +++ "\n"\\e<-errs] io w
+       | not (positionals =: []) = exit 1 ["Positional arguments not allowed"] io w
        # (cs, io) = chars io
        # mstr = case mode of
                MHelp = Left [usageInfo ("Usage: " +++ argv0 +++ " [opts]\n") opts]
@@ -48,5 +51,4 @@ Start w
                MType = (\(e, x)->["type: ",toString x, "\n", toString e]) <$> (lex cs >>= parse >>= check)
                MInterpret = (\x->[toString x]) <$> (lex cs >>= parse >>= check >>= int o fst)
                MGen = lex cs >>= parse >>= check >>= gen o fst
-       = setReturnCode (either (const 1) (const 0) mstr)
-               (snd (fclose (foldr fwrites io (either id id mstr)) w))
+       = exit (either (\_->1) (\_->0) mstr) (either id id mstr) io w