import Data.Either
import Data.Functor
import Data.Func
-import Control.Monad
+import Text
+import Control.Monad => qualified join
import System.GetOpt
import System.CommandLine
:: Mode = MHelp | MLex | MParse | MType | MInterpret | MGen
:: Result
= Lex [Token]
- | Parse [Function]
+ | Parse String
| Type Expression
| Interpret Value
| Gen [String]
= case mode of
MHelp = Left [usageInfo ("Usage: " +++ argv0 +++ " [options]\n") options]
MLex = Lex <$> lex cs
- MParse = Parse <$> (lex cs >>= parse)
+ MParse = Parse <$> join "\n" <$> map toString <$> (lex cs >>= parse)
MType = Type <$> (lex cs >>= parse >>= check)
MInterpret = Interpret <$> (lex cs >>= parse >>= check >>= int)
MGen = Gen <$> (lex cs >>= parse >>= check >>= gen)