aboutsummaryrefslogtreecommitdiff
path: root/pf.icl
diff options
context:
space:
mode:
Diffstat (limited to 'pf.icl')
-rw-r--r--pf.icl35
1 files changed, 16 insertions, 19 deletions
diff --git a/pf.icl b/pf.icl
index a548922..7e0f76f 100644
--- a/pf.icl
+++ b/pf.icl
@@ -1,9 +1,11 @@
module pf
import StdBool
+import StdFile
from StdFunc import flip
import StdMisc
import StdString
+import StdTuple
import GenEq
@@ -14,6 +16,7 @@ from Data.Func import $
import Data.Functor
import Data.List
import Data.Maybe
+import System.CommandLine
import Yard
@@ -153,23 +156,17 @@ moveOutside id (f @ x)
g @ e=:(Ident id) -> Ident "(o)" @ f @ g @ e
moveOutside _ (Lambda x e) = Lambda x e // TODO
-Start = map do
- [ "\\x -> 5"
- , "\\x -> x"
- , "\\x -> y"
- , "\\x y -> x"
- , "\\x y -> y"
- , "\\x y -> 37"
- , "\\x y z -> x"
- , "\\x y z -> y"
- , "\\x y z -> z"
- , "\\x y z -> 37"
- , "\\x y -> x y"
- , "\\x y -> y x"
- , "\\x y -> y 10"
- , "\\f a b c d -> f b c d a"
- , "\\f x -> f x x"
- ]
+Start w
+# ([prg:cmd],w) = getCommandLine w
+| length cmd <> 1 = err ("Usage: " +++ prg +++ " EXPRESSION") w
+# e = parse (hd cmd)
+| isNothing e = err "Expression could not be parsed." w
+# e = fromJust e
+# (io,w) = stdio w
+# io = io <<< "Request: " <<< print e <<< "\n"
+# io = io <<< "Result: " <<< print (optim e) <<< "\n"
+# (_,w) = fclose io w
+= w
where
- do e = (print pe, " ==> ", print (optim pe), "\n")
- where pe = fromJust (parse e)
+ err :: a *World -> *World | <<< a
+ err e w = snd (fclose (stderr <<< e <<< "\n") w)