summaryrefslogtreecommitdiff
path: root/src/PGF/Paraphrase.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-09-08 08:40:28 +0000
committerkrasimir <krasimir@chalmers.se>2009-09-08 08:40:28 +0000
commit28a7c4b5c7659dc18166e06e914fb0a81c1c43bc (patch)
tree3d4a866f0fe37d8b45230581c44f459d7ac16e3d /src/PGF/Paraphrase.hs
parent9940c44259fe3ee4501e324b4d1816a50d77fa37 (diff)
now the datatype Tree is only internal. All API functions are working with Expr directly. Commands gt, gr, p and rf filter out the output via the typechecker
Diffstat (limited to 'src/PGF/Paraphrase.hs')
-rw-r--r--src/PGF/Paraphrase.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/PGF/Paraphrase.hs b/src/PGF/Paraphrase.hs
index fecfe34bb..ee615f6ac 100644
--- a/src/PGF/Paraphrase.hs
+++ b/src/PGF/Paraphrase.hs
@@ -14,6 +14,7 @@ module PGF.Paraphrase (
) where
import PGF.Data
+import PGF.Tree
import PGF.Macros (lookDef,isData)
import PGF.Expr
import PGF.CId
@@ -23,15 +24,18 @@ import qualified Data.Map as Map
import Debug.Trace ----
-paraphrase :: PGF -> Tree -> [Tree]
+paraphrase :: PGF -> Expr -> [Expr]
paraphrase pgf = nub . paraphraseN 2 pgf
-paraphraseN :: Int -> PGF -> Tree -> [Tree]
-paraphraseN 0 _ t = [t]
-paraphraseN i pgf t =
+paraphraseN :: Int -> PGF -> Expr -> [Expr]
+paraphraseN i pgf = map tree2expr . paraphraseN' i pgf . expr2tree
+
+paraphraseN' :: Int -> PGF -> Tree -> [Tree]
+paraphraseN' 0 _ t = [t]
+paraphraseN' i pgf t =
step i t ++ [Fun g ts' | Fun g ts <- step (i-1) t, ts' <- sequence (map par ts)]
where
- par = paraphraseN (i-1) pgf
+ par = paraphraseN' (i-1) pgf
step 0 t = [t]
step i t = let stept = step (i-1) t in stept ++ concat [def u | u <- stept]
def = fromDef pgf