summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorKrasimir Angelov <kr.angelov@gmail.com>2017-08-30 18:11:59 +0200
committerKrasimir Angelov <kr.angelov@gmail.com>2017-08-30 18:11:59 +0200
commitcd53269f96873f228e196cb6d22d101c5e4f50ed (patch)
tree8998df85bf55b8a228ff95f1b2c3febef6505e8a /src/runtime
parentfd56b4b5f3d08cabb807f2ea5f397da38cc26a0a (diff)
bugfix for hasLinearization in the Haskell binding
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/c/pgf/pgf.c2
-rw-r--r--src/runtime/c/pgf/pgf.h2
-rw-r--r--src/runtime/haskell-bind/PGF2.hsc5
-rw-r--r--src/runtime/haskell-bind/PGF2/FFI.hs2
4 files changed, 6 insertions, 5 deletions
diff --git a/src/runtime/c/pgf/pgf.c b/src/runtime/c/pgf/pgf.c
index a8c6bb800..a1649b9ff 100644
--- a/src/runtime/c/pgf/pgf.c
+++ b/src/runtime/c/pgf/pgf.c
@@ -195,7 +195,7 @@ pgf_print_name(PgfConcr* concr, PgfCId id)
return name;
}
-PGF_API bool
+PGF_API int
pgf_has_linearization(PgfConcr* concr, PgfCId id)
{
PgfCncOverloadMap* overl_table =
diff --git a/src/runtime/c/pgf/pgf.h b/src/runtime/c/pgf/pgf.h
index cf2d85212..632a1d332 100644
--- a/src/runtime/c/pgf/pgf.h
+++ b/src/runtime/c/pgf/pgf.h
@@ -94,7 +94,7 @@ pgf_function_prob(PgfPGF* pgf, PgfCId funname);
PGF_API_DECL GuString
pgf_print_name(PgfConcr*, PgfCId id);
-PGF_API_DECL bool
+PGF_API_DECL int
pgf_has_linearization(PgfConcr* concr, PgfCId id);
PGF_API_DECL void
diff --git a/src/runtime/haskell-bind/PGF2.hsc b/src/runtime/haskell-bind/PGF2.hsc
index a23982465..93158213f 100644
--- a/src/runtime/haskell-bind/PGF2.hsc
+++ b/src/runtime/haskell-bind/PGF2.hsc
@@ -580,8 +580,9 @@ parseWithOracle lang cat sent (predict,complete,literal) =
-- | Returns True if there is a linearization defined for that function in that language
hasLinearization :: Concr -> Fun -> Bool
hasLinearization lang id = unsafePerformIO $
- withGuPool $ \pl ->
- newUtf8CString id pl >>= pgf_has_linearization (concr lang)
+ withGuPool $ \pl -> do
+ res <- newUtf8CString id pl >>= pgf_has_linearization (concr lang)
+ return (res /= 0)
-- | Linearizes an expression as a string in the language
linearize :: Concr -> Expr -> String
diff --git a/src/runtime/haskell-bind/PGF2/FFI.hs b/src/runtime/haskell-bind/PGF2/FFI.hs
index d01084d62..7379aa723 100644
--- a/src/runtime/haskell-bind/PGF2/FFI.hs
+++ b/src/runtime/haskell-bind/PGF2/FFI.hs
@@ -192,7 +192,7 @@ foreign import ccall "pgf/pgf.h pgf_print_name"
pgf_print_name :: Ptr PgfConcr -> CString -> IO CString
foreign import ccall "pgf/pgf.h pgf_has_linearization"
- pgf_has_linearization :: Ptr PgfConcr -> CString -> IO Bool
+ pgf_has_linearization :: Ptr PgfConcr -> CString -> IO CInt
foreign import ccall "pgf/pgf.h pgf_linearize"
pgf_linearize :: Ptr PgfConcr -> PgfExpr -> Ptr GuOut -> Ptr GuExn -> IO ()