mutual recursion type inference
[minfp.git] / main.icl
index 6b181af..69d66e6 100644 (file)
--- a/main.icl
+++ b/main.icl
@@ -3,7 +3,8 @@ module main
 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
 
@@ -46,9 +47,13 @@ Start w
        # (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"
+
+