module CatchMain where import Language.Haskell.Pretty import Target import RecType import CatchParser 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"] 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 utilTry = "try 1/0 catch \\ _ -> 99999" utilAmb = "(amb 1 or \\ _ -> 2) * (amb 3 or \\ _ -> 4)" utilFactDecl = "fact = \\ n -> if n<=1 then 1 else n*fact(amb n-1 or \\ _ -> n-2)" utilFact = "let " ++ utilFactDecl ++ " in fact 9" -- for example, -- putStrLn $ test False utilTry -- putStrLn $ test False utilAmb -- putStrLn $ test False utilFact