summaryrefslogtreecommitdiff
path: root/src/GF/Canon
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2007-01-10 21:03:18 +0000
committeraarne <aarne@cs.chalmers.se>2007-01-10 21:03:18 +0000
commit935594eb86a16532108f707b5dcfd351271d80b9 (patch)
treeed41deeb003f8f601a3c54661f946f577056b73e /src/GF/Canon
parent0882e5eac274f11a0cd3a98fa93c57d6ee479981 (diff)
semantics of variants
Diffstat (limited to 'src/GF/Canon')
-rw-r--r--src/GF/Canon/Look.hs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/GF/Canon/Look.hs b/src/GF/Canon/Look.hs
index 1ac39c695..2fc652c81 100644
--- a/src/GF/Canon/Look.hs
+++ b/src/GF/Canon/Look.hs
@@ -125,8 +125,22 @@ allParamValues cnc ptyp = case ptyp of
-- runtime computation on GFC objects
ccompute :: CanonGrammar -> [Term] -> Term -> Err Term
-ccompute cnc = comp []
+ccompute cnc = vcomp
where
+
+ vcomp xs t = do
+ let xss = variations xs
+ ts <- mapM (\xx -> comp [] xx t) xss
+ return $ variants ts
+
+ variations xs = combinations [getVariants t | t <- xs]
+ variants ts = case ts of
+ [t] -> t
+ _ -> FV ts
+ getVariants t = case t of
+ FV ts -> ts
+ _ -> [t]
+
comp g xs t = case t of
Arg (A _ i) -> err (const (return t)) return $ xs !? fromInteger i
Arg (AB _ _ i) -> err (const (return t)) return $ xs !? fromInteger i