added composOp generation to haskell-gadt, and an example in examples/gadt-transfer

This commit is contained in:
aarne
2011-03-05 22:25:03 +00:00
parent 34daa2894a
commit 54feac5d26
7 changed files with 239 additions and 4 deletions

View File

@@ -0,0 +1,23 @@
{-# OPTIONS_GHC -fglasgow-exts #-}
module Main where
import PGF
import Foods
-- example of using GADT: turn every occurrence of "boring" to "very boring"
main = do
pgf <- readPGF "Foods.pgf"
interact (doVery pgf)
doVery pgf s = case parseAllLang pgf (startCat pgf) s of
(l,t:_):_ -> unlines $ return $ linearize pgf l $ gf $ veryC $ fg t
veryC :: GComment -> GComment
veryC = very
very :: forall a. Foods.Tree a -> Foods.Tree a
very t = case t of
GBoring -> GVery GBoring
_ -> composOp very t