haskell-bind: change the type of CRuntimeFFI.getConcr

Change the type of getConcr from

    getConcr :: PGF -> Language -> Concr

to

    getConcr :: PGF -> Language -> Maybe Concr

This is to prevent programs from crashing later if you try to select a
concrete syntax that is not present in a grammar.
This commit is contained in:
hallgren
2014-01-17 13:58:48 +00:00
parent aea787aded
commit 33024f3130

View File

@@ -72,11 +72,11 @@ readPGF filepath =
return PGF {pgfPool = pool, pgf = pgf}
getConcr :: PGF -> Language -> Concr
getConcr :: PGF -> Language -> Maybe Concr
getConcr p (CId lang) = unsafePerformIO $
BS.useAsCString lang $ \lng -> do
cnc <- pgf_get_language (pgf p) lng
return (Concr cnc p)
return (if cnc==nullPtr then Nothing else Just (Concr cnc p))