The file MiniLang.hs
in this directory has been generated automatically with the following command.
gf -make -f haskell --haskell=pgf2 --haskell=lexical --lexical=A,Adv,Conj,Det,N,PN,Pron,Prep,V,V2 ../resource/MiniLangEng.gf
The generated files are almost identical. Run the following command:
diff ../MiniLang.hs MiniLang.hs
The diff is very small:
< import PGF hiding (Tree)
---
> import PGF2 hiding (Tree)
>
> showCId :: CId -> String
> showCId = id
So the module that is imported is now PGF2 instead of PGF, and the function showCId is added, because in PGF2, the type CId
is actually just an alias for String
, not a separate type like in the PGF module.
How about the file that we wrote to do the transfer? Here I gave it a different name, and you can run the diff
command again to see for yourself.
diff ../ReflTransfer.hs ReflTransferWithPGF2.hs
None of the tree transformation functions are different, only the ones using the PGF(2) library. Some of the type signatures are different:
-
parse :: PGF -> Language -> Type -> String -> [Tree]
-
parse :: Concr -> Type -> String -> ParseOutput [(Expr, Float)]
If you look at the type signatures carefully, you'll notice that the first two arguments to PGF.parse
(PGF and Language) correspond to the single first arguments to PGF2.parse
(Concr). So the first step in PGF2 is to extract a Concr using the function PGF2.languages
to get a map, and then accessing the map with the language name, which is just a String.
Both of the following are somewhat incomplete, but still useful.
If you have any questions about things that aren't documented, feel free to can ask on Stack Overflow, GF Discord server or GF mailing list.