From 38f468eed3325d5e435021b8b137f80545f22a95 Mon Sep 17 00:00:00 2001 From: "John J. Camilleri" Date: Sat, 11 Jul 2020 21:06:08 +0200 Subject: (pgf2) Readme, license, changelog --- src/runtime/haskell-bind/README.md | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/runtime/haskell-bind/README.md (limited to 'src/runtime/haskell-bind/README.md') diff --git a/src/runtime/haskell-bind/README.md b/src/runtime/haskell-bind/README.md new file mode 100644 index 000000000..a4ce0ef20 --- /dev/null +++ b/src/runtime/haskell-bind/README.md @@ -0,0 +1,46 @@ +# PGF2 + +This is a Haskell binding to the PGF runtime 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 + +``` +cabal install +``` + +**Note:** you must have the PGF C runtime already installed and available. +See + +## How to use + +Import PGF to the Haskell program that you're writing. +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 +``` -- cgit v1.2.3