summaryrefslogtreecommitdiff
path: root/examples/gadt-transfer/VeryFoods.hs
blob: ad6b6dc7f5cbde8503ba8b4b239315177c568ae6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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