From 79ea4af960168021421152f7d5b8070892aa76e1 Mon Sep 17 00:00:00 2001 From: krasimir Date: Wed, 25 Nov 2015 10:37:13 +0000 Subject: added readTriple in libsg and its Haskell binding --- src/runtime/haskell-bind/SG.hsc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/runtime/haskell-bind/SG.hsc') diff --git a/src/runtime/haskell-bind/SG.hsc b/src/runtime/haskell-bind/SG.hsc index 37bc074b3..3f7baa5fd 100644 --- a/src/runtime/haskell-bind/SG.hsc +++ b/src/runtime/haskell-bind/SG.hsc @@ -8,7 +8,8 @@ module SG( SG, openSG, closeSG , beginTrans, commit, rollback, inTransaction , SgId , insertExpr, getExpr - , readTriple, insertTriple, getTriple + , readTriple, showTriple + , insertTriple, getTriple , queryTriple ) where @@ -128,6 +129,21 @@ readTriple str = else do gu_pool_free exprPl return Nothing +showTriple :: Expr -> Expr -> Expr -> String +showTriple (Expr expr1 _) (Expr expr2 _) (Expr expr3 _) = + unsafePerformIO $ + withGuPool $ \tmpPl -> + withTriple $ \triple -> do + (sb,out) <- newOut tmpPl + let printCtxt = nullPtr + exn <- gu_new_exn tmpPl + pokeElemOff triple 0 expr1 + pokeElemOff triple 1 expr2 + pokeElemOff triple 2 expr3 + pgf_print_expr_tuple 3 triple printCtxt out exn + s <- gu_string_buf_freeze sb tmpPl + peekCString s + insertTriple :: SG -> Expr -> Expr -> Expr -> IO SgId insertTriple (SG sg) (Expr expr1 _) (Expr expr2 _) (Expr expr3 _) = withGuPool $ \tmpPl -> -- cgit v1.2.3