@@ -98,7 +98,8 @@ doExec env ctxt Impossible = fail "Tried to execute an impossible case"
9898doExec env ctxt (TType u) = return (TType u)
9999
100100execApp :: Env -> Context -> (Term, [Term]) -> Idris Term
101−execApp env ctxt (f, args) = do newF <- doExec env ctxt f
101+execApp env ctxt (f, args) = trace ("Reducing " ++ show f) $
102+ do newF <- doExec env ctxt f
102103 newArgs <- mapM (doExec env ctxt) args
103104 execApp' env ctxt newF newArgs
104105
@@ -117,6 +118,19 @@ execApp' env ctxt (P _ (UN "prim__readString") _) [P _ (UN "prim__stdin") _] =
117118execApp' env ctxt (P _ (UN "prim__concat") _) [(Constant (Str s1)), (Constant (Str s2))] =
118119 return $ Constant (Str (s1 ++ s2))
119120
121+execApp' env ctxt (P _ (UN "prim__eqInt") _) [(Constant (I i1)), (Constant (I i2))] =
122+ return $ if i1 == i2 then Constant (I 1) else Constant (I 0)
123+
124+execApp' env ctxt (P _ (UN "prim__readString") _) [ptr] | Just p <- unPtr ptr =
125+ do fn <- findForeign "freadStr"
126+ case fn of
127+ Just (Fun _ freadStr) -> do
128+ res <- lift $ callFFI freadStr retCString [argPtr p]
129+ str <- lift $ peekCString res
130+ trace ("Found " ++ str) $ return ()
131+ return $ Constant (Str str)
132+ Nothing -> fail "Could not load freadStr"
133+
120134execApp' env ctxt f@(P _ n _) args =
121135 do let val = lookupDef Nothing n ctxt
122136 case val of