mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-11 12:12:51 -06:00
an unsafe API for adding functions to the grammar. breaks referential transparency
This commit is contained in:
@@ -40,6 +40,8 @@ module PGF2 (-- * PGF
|
||||
mkType, unType,
|
||||
mkHypo, mkDepHypo, mkImplHypo,
|
||||
|
||||
createFunction,
|
||||
|
||||
-- * Concrete syntax
|
||||
ConcName,
|
||||
|
||||
@@ -315,3 +317,10 @@ readType str =
|
||||
freeStablePtr c_ty
|
||||
return (Just ty)
|
||||
|
||||
createFunction :: PGF -> Fun -> Type -> Float -> IO ()
|
||||
createFunction p name ty prob =
|
||||
withForeignPtr (a_pgf p) $ \p_pgf ->
|
||||
withText name $ \c_name ->
|
||||
bracket (newStablePtr ty) freeStablePtr $ \c_ty ->
|
||||
withForeignPtr marshaller $ \m -> do
|
||||
pgf_create_function p_pgf c_name c_ty prob m
|
||||
|
||||
@@ -101,6 +101,10 @@ foreign import ccall "pgf/expr.h pgf_function_is_constructor"
|
||||
foreign import ccall "pgf/expr.h pgf_function_is_constructor"
|
||||
pgf_function_prob :: Ptr PgfPGF -> Ptr PgfText -> IO (#type prob_t)
|
||||
|
||||
foreign import ccall "pgf_create_function"
|
||||
pgf_create_function :: Ptr PgfPGF -> Ptr PgfText -> StablePtr Type -> (#type prob_t) -> Ptr PgfMarshaller -> IO ()
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- Texts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user