module RecMain where import Language.Haskell.Pretty import Target import RecType import RecParser import RecCompiler primitives = map (\ n -> (n, mkOp n)) ["*", "+", "-", "++", ":", "==", "/=", "<", "<=", ">=", ">"] ++ map (\ n -> (n, divOp n)) ["/", "%"] ++ map (\ n -> (n, mkPrimN 2 n)) ["tryM","appendM"] ++ map (\ n -> (n, mkPureN 1 n)) ["not","null", "head", "tail", "show", "atoi", "atof"] test useDo prog = prettyPrint $ translateToHs useDo $ removeSugar False $ simplify $ instOnce primitives $ deBruijn $ comp $ myParse prog testDecls useDo prog = concat $ map (\ str -> str ++ "\n") $ map prettyPrint $ translateToHsDecls useDo $ removeSugarDecls False $ simplifyDecls $ instOnceDecls primitives $ deBruijnDecls $ compDecls $ myParseDecls prog utilFactDecl = "fact = \\ n -> if n==0 then 1 else n*fact(n-1)" utilFact = "let " ++ utilFactDecl ++ " in fact 9" utilSTFactDecl = "fact = \\ n ->\n" ++ " begin\n" ++ " setX 1;\n" ++ " setY n;\n" ++ " while getY () > 0 do\n" ++ " begin\n" ++ " setX (getX ()*getY ());\n" ++ " setY (getY () - 1)\n" ++ " end;\n" ++ " getX ()\n" ++ " end\n" utilSTFact = "let " ++ utilSTFactDecl ++ "in fact 9" -- for example, -- putStrLn $ test False utilFact -- putStrLn $ test False utilSTFact