@@ -98,7 +98,8 @@ doExec env ctxt Impossible = fail "Tried to execute an impossible case"
98doExec env ctxt (TType u) = return (TType u)
98doExec env ctxt (TType u) = return (TType u)
100execApp :: Env -> Context -> (Term, [Term]) -> Idris Term
100execApp :: Env -> Context -> (Term, [Term]) -> Idris Term
101+execApp env ctxt (f, args) = trace ("Reducing " ++ show f) $
101−execApp env ctxt (f, args) = do newF <- doExec env ctxt f
102+ do newF <- doExec env ctxt f
102 newArgs <- mapM (doExec env ctxt) args
103 newArgs <- mapM (doExec env ctxt) args
103 execApp' env ctxt newF newArgs
104 execApp' env ctxt newF newArgs
@@ -117,6 +118,19 @@ execApp' env ctxt (P _ (UN "prim__readString") _) [P _ (UN "prim__stdin") _] =
117execApp' env ctxt (P _ (UN "prim__concat") _) [(Constant (Str s1)), (Constant (Str s2))] =
118execApp' env ctxt (P _ (UN "prim__concat") _) [(Constant (Str s1)), (Constant (Str s2))] =
118 return $ Constant (Str (s1 ++ s2))
119 return $ Constant (Str (s1 ++ s2))
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)
124+execApp' env ctxt (P _ (UN "prim__readString") _) [ptr] | Just p <- unPtr ptr =
125+ do fn <- findForeign "freadStr"
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"
120execApp' env ctxt f@(P _ n _) args =
134execApp' env ctxt f@(P _ n _) args =
121 do let val = lookupDef Nothing n ctxt
135 do let val = lookupDef Nothing n ctxt
122 case val of
136 case val of