summaryrefslogtreecommitdiff
path: root/src/runtime/haskell-bind
diff options
context:
space:
mode:
authorKrasimir Angelov <kr.angelov@gmail.com>2017-09-01 08:46:52 +0200
committerKrasimir Angelov <kr.angelov@gmail.com>2017-09-01 08:46:52 +0200
commit5a37660811d2b23439a542c70cd09bdda9418a1a (patch)
tree2d5adac94b7d5ac7a4b69aca3cfdfd4927f00b99 /src/runtime/haskell-bind
parent1182a9b63d983a749829d774ef05e3dd7dfe6a8e (diff)
added function treeProbability in the Haskell binding
Diffstat (limited to 'src/runtime/haskell-bind')
-rw-r--r--src/runtime/haskell-bind/PGF2.hsc9
-rw-r--r--src/runtime/haskell-bind/PGF2/FFI.hs3
2 files changed, 12 insertions, 0 deletions
diff --git a/src/runtime/haskell-bind/PGF2.hsc b/src/runtime/haskell-bind/PGF2.hsc
index 4523279dd..54c413a34 100644
--- a/src/runtime/haskell-bind/PGF2.hsc
+++ b/src/runtime/haskell-bind/PGF2.hsc
@@ -39,6 +39,8 @@ module PGF2 (-- * PGF
mkFloat,unFloat,
mkMeta,unMeta,
mkCId,
+ treeProbability,
+
-- ** Types
Type, Hypo, BindType(..), startCat,
readType, showType,
@@ -314,6 +316,13 @@ compute (PGF p _) (Expr c_expr touch1) =
gu_pool_free exprPl
throwIO (PGFError msg)
+treeProbability :: PGF -> Expr -> Float
+treeProbability (PGF p _) (Expr c_expr touch1) =
+ unsafePerformIO $ do
+ res <- pgf_compute_tree_probability p c_expr
+ touch1
+ return (realToFrac res)
+
-----------------------------------------------------------------------------
-- Graphviz
diff --git a/src/runtime/haskell-bind/PGF2/FFI.hs b/src/runtime/haskell-bind/PGF2/FFI.hs
index 1a5e7f91b..65dd81085 100644
--- a/src/runtime/haskell-bind/PGF2/FFI.hs
+++ b/src/runtime/haskell-bind/PGF2/FFI.hs
@@ -325,6 +325,9 @@ foreign import ccall "pgf/pgf.h pgf_expr_unlit"
foreign import ccall "pgf/expr.h pgf_expr_arity"
pgf_expr_arity :: PgfExpr -> IO CInt
+foreign import ccall "pgf/expr.h pgf_compute_tree_probability"
+ pgf_compute_tree_probability :: Ptr PgfPGF -> PgfExpr -> IO CFloat
+
foreign import ccall "pgf/expr.h pgf_check_expr"
pgf_check_expr :: Ptr PgfPGF -> Ptr PgfExpr -> PgfType -> Ptr GuExn -> Ptr GuPool -> IO ()