mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-26 03:08:55 -06:00
added composOp generation to haskell-gadt, and an example in examples/gadt-transfer
This commit is contained in:
23
examples/gadt-transfer/VeryFoods.hs
Normal file
23
examples/gadt-transfer/VeryFoods.hs
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user