1
0
forked from GitHub/gf-core

added showContext

This commit is contained in:
krangelov
2021-09-14 19:10:01 +02:00
parent 3675e5cfc6
commit a7bf47cb87
6 changed files with 51 additions and 18 deletions

View File

@@ -912,7 +912,13 @@ showType scope ty =
peekText c_text
showContext :: [Var] -> [(BindType,Var,Type)] -> String
showContext = error "TODO: showContext"
showContext scope hypos =
unsafePerformIO $
withHypos hypos $ \n_hypos c_hypos ->
bracket (newPrintCtxt scope) freePrintCtxt $ \pctxt ->
withForeignPtr marshaller $ \m ->
bracket (pgf_print_context n_hypos c_hypos pctxt 0 m) free $ \c_text ->
peekText c_text
-- | parses a 'String' as a type
readType :: String -> Maybe Type

View File

@@ -78,6 +78,8 @@ foreign import ccall pgf_read_expr_ex :: Ptr PgfText -> Ptr CString -> Ptr PgfUn
foreign import ccall "pgf_print_type"
pgf_print_type :: StablePtr Type -> Ptr PgfPrintContext -> CInt -> Ptr PgfMarshaller -> IO (Ptr PgfText)
foreign import ccall pgf_print_context :: CSize -> Ptr PgfTypeHypo -> Ptr PgfPrintContext -> CInt -> Ptr PgfMarshaller -> IO (Ptr PgfText)
foreign import ccall "pgf_read_type"
pgf_read_type :: Ptr PgfText -> Ptr PgfUnmarshaller -> IO (StablePtr Type)