diff options
| author | John J. Camilleri <john@johnjcamilleri.com> | 2020-08-03 10:53:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-03 10:53:51 +0200 |
| commit | e10bb790cb257bc025e6256cd8c8a6bbba542754 (patch) | |
| tree | 89678b42b9a703d67d25eebe1cf394797d994585 /src/runtime/haskell-bind/README.md | |
| parent | 830dbe760db2df0c573c06cb481d0611bf55908b (diff) | |
| parent | c53353f08763fbbfb5c0abeaa03da6a23aa64080 (diff) | |
Merge pull request #69 from GrammaticalFramework/pgf2-hackage
Update pgf2 metadata for uploading to Hackage
Even though this isn't able to package the C runtime itself into the Haskell package, I think these changes are still worth merging into master.
Diffstat (limited to 'src/runtime/haskell-bind/README.md')
| -rw-r--r-- | src/runtime/haskell-bind/README.md | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/runtime/haskell-bind/README.md b/src/runtime/haskell-bind/README.md new file mode 100644 index 000000000..1cb68df65 --- /dev/null +++ b/src/runtime/haskell-bind/README.md @@ -0,0 +1,56 @@ +# PGF2 + +This is a Haskell binding to the PGF runtime written in C. + +The exposed modules are: + +- `PGF2`: a user API similar to Python and Java APIs +- `PGF2.Internal`: an internal module with FFI definitions for the relevant C functions + +## How to compile + +**Important:** You must have the C runtime already installed and available on your system. +See <https://github.com/GrammaticalFramework/gf-core/blob/master/src/runtime/c/INSTALL> + +Once the runtine is installed, you can install the library to your global Cabal installation: + +``` +cabal install pgf2 --extra-lib-dirs=/usr/local/lib +``` + +or add it to your `stack.yaml` file: + +```yaml +extra-deps: + - pgf2 +extra-lib-dirs: + - /usr/local/lib +``` + +## How to use + +Simply import `PGF2` in your Haskell program. +The Cabal infrastructure will make sure to tell the compiler where to find the relevant modules. + +## Example + +```haskell +module Main where + +import PGF2 +import qualified Data.Map as Map + +main = do + pgf <- readPGF "App12.pgf" + let Just eng = Map.lookup "AppEng" (languages pgf) + + -- Parsing + let res = parse eng (startCat pgf) "this is a small theatre" + let ParseOk ((tree,prob):rest) = res + print tree + + -- Linearisation + let Just expr = readExpr "AdjCN (PositA red_A) (UseN theatre_N)" + let s = linearize eng expr + print s +``` |
