updates'
[minfp.git] / main.icl
index 9f9fd86..136c0e1 100644 (file)
--- a/main.icl
+++ b/main.icl
@@ -32,20 +32,21 @@ opts =
        , Option ['g'] ["gen"]       (NoArg (const MGen))       "Up to and including generation"
        ]
 
-Start :: *World -> Either [String] [String]
+Start :: *World -> *World
 Start 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 =: []) = Left ["Positional arguments not allowed"]
+//     | not (errs =: []) = Left [e +++ "\n"\\e<-errs]
+//     | not (positionals =: []) = die ["Positional arguments not allowed"] w
        # (io, w) = stdio w
        # (cs, io) = chars io
-       # (_, w) = fclose io w
-       = case mode of
+       # mstr = case mode of
                MHelp = Left [usageInfo ("Usage: " +++ argv0 +++ " [opts]\n") opts]
                MLex = map (\x->toString x +++ "\n") <$> lex cs
                MParse = map (\x->toString x +++ "\n") <$> (lex cs >>= parse)
                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))