mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-24 02:12:50 -06:00
added exprHash in the Haskell binding
This commit is contained in:
@@ -39,6 +39,7 @@ module PGF2 (-- * PGF
|
|||||||
mkFloat,unFloat,
|
mkFloat,unFloat,
|
||||||
mkMeta,unMeta,
|
mkMeta,unMeta,
|
||||||
mkCId,
|
mkCId,
|
||||||
|
exprHash,
|
||||||
treeProbability,
|
treeProbability,
|
||||||
|
|
||||||
-- ** Types
|
-- ** Types
|
||||||
@@ -323,6 +324,15 @@ treeProbability (PGF p _) (Expr c_expr touch1) =
|
|||||||
touch1
|
touch1
|
||||||
return (realToFrac res)
|
return (realToFrac res)
|
||||||
|
|
||||||
|
exprHash :: Int32 -> Expr -> Int32
|
||||||
|
exprHash h (Expr c_expr touch1) =
|
||||||
|
unsafePerformIO $ do
|
||||||
|
h <- pgf_expr_hash (fromIntegral h) c_expr
|
||||||
|
touch1
|
||||||
|
return (fromIntegral h)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Graphviz
|
-- Graphviz
|
||||||
|
|
||||||
|
|||||||
@@ -328,6 +328,9 @@ foreign import ccall "pgf/expr.h pgf_expr_arity"
|
|||||||
foreign import ccall "pgf/expr.h pgf_expr_eq"
|
foreign import ccall "pgf/expr.h pgf_expr_eq"
|
||||||
pgf_expr_eq :: PgfExpr -> PgfExpr -> IO CInt
|
pgf_expr_eq :: PgfExpr -> PgfExpr -> IO CInt
|
||||||
|
|
||||||
|
foreign import ccall "pgf/expr.h pgf_expr_hash"
|
||||||
|
pgf_expr_hash :: Word -> PgfExpr -> IO Word
|
||||||
|
|
||||||
foreign import ccall "pgf/expr.h pgf_compute_tree_probability"
|
foreign import ccall "pgf/expr.h pgf_compute_tree_probability"
|
||||||
pgf_compute_tree_probability :: Ptr PgfPGF -> PgfExpr -> IO CFloat
|
pgf_compute_tree_probability :: Ptr PgfPGF -> PgfExpr -> IO CFloat
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user