import StdEnv
import Data.Either
import Data.Functor
-import Control.Monad => qualified join
+import Data.List
+import Control.Monad
import System.GetOpt
import System.CommandLine
# (cs, io) = chars io
# 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)
+ MLex = map (nl o toString) <$> lex cs
+ MParse = map (nl o toString) <$> (lex cs >>= parse)
+ MType = map (\(t, s)->nl (toString t +++ " :: " +++ toString s)) o snd <$> (lex cs >>= parse >>= check)
+ MInterpret = pure o toString <$> (lex cs >>= parse >>= check >>= int o fst)
MGen = lex cs >>= parse >>= check >>= gen o fst
= exit (either (\_->1) (\_->0) mstr) (either id id mstr) io w
+
+nl x = x +++ "\n"
+
+