Comment out some dead code found with -fwarn-unused-binds

Also fixed some warnings and tightened some imports
This commit is contained in:
hallgren
2015-08-28 13:59:43 +00:00
parent 68ff5ff371
commit f62edb3e1e
39 changed files with 122 additions and 116 deletions

View File

@@ -61,7 +61,7 @@ import Control.Applicative
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- XXX Strict in buffer only. -- XXX Strict in buffer only.
data PairS a = PairS a {-# UNPACK #-}!Builder data PairS a = PairS a {-UNPACK-}!Builder
sndS :: PairS a -> Builder sndS :: PairS a -> Builder
sndS (PairS _ b) = b sndS (PairS _ b) = b

View File

@@ -9,7 +9,6 @@ import GF.Command.Parse
import PGF.Internal(Expr(..)) import PGF.Internal(Expr(..))
import GF.Infra.UseIO(putStrLnE) import GF.Infra.UseIO(putStrLnE)
import GF.Text.Pretty(render)
import Control.Monad(when) import Control.Monad(when)
import qualified Data.Map as Map import qualified Data.Map as Map

View File

@@ -4,7 +4,7 @@ module GF.Command.TreeOperations (
treeChunks treeChunks
) where ) where
import PGF import PGF(PGF,CId,compute,unApp,paraphrase)
import PGF.Internal(Expr(..),unAppForm) import PGF.Internal(Expr(..),unAppForm)
import Data.List import Data.List

View File

@@ -33,7 +33,7 @@ nfx env@(GE _ _ _ loc) t = value2term loc [] # eval env t
eval :: GlobalEnv -> Term -> Err Value eval :: GlobalEnv -> Term -> Err Value
eval ge t = ($[]) # value (toplevel ge) t eval ge t = ($[]) # value (toplevel ge) t
apply env = apply' env --apply env = apply' env
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@@ -279,7 +279,7 @@ strsFromValue t = case t of
d0 <- strsFromValue d d0 <- strsFromValue d
v0 <- mapM (strsFromValue . fst) vs v0 <- mapM (strsFromValue . fst) vs
c0 <- mapM (strsFromValue . snd) vs c0 <- mapM (strsFromValue . snd) vs
let vs' = zip v0 c0 --let vs' = zip v0 c0
return [strTok (str2strings def) vars | return [strTok (str2strings def) vars |
def <- d0, def <- d0,
vars <- [[(str2strings v, map sstr c) | (v,c) <- zip vv c0] | vars <- [[(str2strings v, map sstr c) | (v,c) <- zip vv c0] |
@@ -511,11 +511,11 @@ ix loc fn xs i =
else bugloc loc $ "(!!): index too large in "++fn++", "++show i++"<"++show n else bugloc loc $ "(!!): index too large in "++fn++", "++show i++"<"++show n
where n = length xs where n = length xs
infixl 1 #,<#,@@ infixl 1 #,<# --,@@
f # x = fmap f x f # x = fmap f x
mf <# mx = ap mf mx mf <# mx = ap mf mx
m1 @@ m2 = (m1 =<<) . m2 --m1 @@ m2 = (m1 =<<) . m2
both f (x,y) = (,) # f x <# f y both f (x,y) = (,) # f x <# f y

View File

@@ -2,7 +2,7 @@
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-} {-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
module GF.Compile.Compute.Predef(predef,predefName,delta) where module GF.Compile.Compute.Predef(predef,predefName,delta) where
import GF.Text.Pretty(render,hang) --import GF.Text.Pretty(render,hang)
import qualified Data.Map as Map import qualified Data.Map as Map
import Data.Array(array,(!)) import Data.Array(array,(!))
import Data.List (isInfixOf) import Data.List (isInfixOf)
@@ -146,11 +146,11 @@ norm v =
(VString s1,VString s2) -> VString (s1++" "++s2) (VString s1,VString s2) -> VString (s1++" "++s2)
(v1,v2) -> VC v1 v2 (v1,v2) -> VC v1 v2
_ -> v _ -> v
{-
strict v = case v of strict v = case v of
VError err -> Left err VError err -> Left err
_ -> Right v _ -> Right v
-}
string s = case words s of string s = case words s of
[] -> VString "" [] -> VString ""
ss -> foldr1 VC (map VString ss) ss -> foldr1 VC (map VString ss)
@@ -158,7 +158,8 @@ string s = case words s of
--- ---
swap (x,y) = (y,x) swap (x,y) = (y,x)
{-
bug msg = ppbug msg bug msg = ppbug msg
ppbug doc = error $ render $ ppbug doc = error $ render $
hang "Internal error in Compute.Predef:" 4 doc hang "Internal error in Compute.Predef:" 4 doc
-}

View File

@@ -126,7 +126,7 @@ toHaskell gId gr absname cenv (name,jment) =
[Right (cat,(Eqn (prefixIdent "lin" cat,lhs),coerce [] lincat rhs))] [Right (cat,(Eqn (prefixIdent "lin" cat,lhs),coerce [] lincat rhs))]
where where
Ok abstype = lookupFunType gr absname name Ok abstype = lookupFunType gr absname name
(absctx,abscat,absargs) = typeForm abstype (absctx,_abscat,_absargs) = typeForm abstype
e' = unAbs (length params) $ e' = unAbs (length params) $
nf loc (mkAbs params (mkApp def (map Vr args))) nf loc (mkAbs params (mkApp def (map Vr args)))

View File

@@ -149,7 +149,7 @@ compileFun gr eval st vs (Let (x, (_, e1)) e2) h0 bs args =
compileFun gr eval st vs e@(Glue e1 e2) h0 bs args = compileFun gr eval st vs e@(Glue e1 e2) h0 bs args =
let eval' st fun args = [PUSH_FRAME]++is++[EVAL fun' RecCall] let eval' st fun args = [PUSH_FRAME]++is++[EVAL fun' RecCall]
where where
(st1,is) = pushArgs (st+2) (reverse args) (_st1,is) = pushArgs (st+2) (reverse args)
fun' = shiftIVal st fun fun' = shiftIVal st fun
flatten (Glue e1 e2) h0 bs = flatten (Glue e1 e2) h0 bs =

View File

@@ -177,8 +177,8 @@ genCncCats gr am cm cdefs =
(index',cats) = mkCncCats index cdefs (index',cats) = mkCncCats index cdefs
in (index', (i2i id,cc) : cats) in (index', (i2i id,cc) : cats)
| otherwise = | otherwise =
let cc@(C.CncCat s e _) = pgfCncCat gr lincat index let cc@(C.CncCat _s e _) = pgfCncCat gr lincat index
(index',cats) = mkCncCats (e+1) cdefs (index',cats) = mkCncCats (e+1) cdefs
in (index', (i2i id,cc) : cats) in (index', (i2i id,cc) : cats)
mkCncCats index (_ :cdefs) = mkCncCats index cdefs mkCncCats index (_ :cdefs) = mkCncCats index cdefs
@@ -303,6 +303,6 @@ genPrintNames cdefs =
flatten (Alts x _) = flatten x flatten (Alts x _) = flatten x
flatten (C x y) = flatten x +++ flatten y flatten (C x y) = flatten x +++ flatten y
mkArray lst = listArray (0,length lst-1) lst --mkArray lst = listArray (0,length lst-1) lst
mkMapArray map = array (0,Map.size map-1) [(v,k) | (k,v) <- Map.toList map] mkMapArray map = array (0,Map.size map-1) [(v,k) | (k,v) <- Map.toList map]
mkSetArray set = listArray (0,Set.size set-1) [v | v <- Set.toList set] mkSetArray set = listArray (0,Set.size set-1) [v | v <- Set.toList set]

View File

@@ -273,13 +273,13 @@ hSkeleton gr =
valtyps (_, (_,x)) (_, (_,y)) = compare x y valtyps (_, (_,x)) (_, (_,y)) = compare x y
valtypg (_, (_,x)) (_, (_,y)) = x == y valtypg (_, (_,x)) (_, (_,y)) = x == y
jty (f,(ty,_,_,_)) = (f,catSkeleton ty) jty (f,(ty,_,_,_)) = (f,catSkeleton ty)
{-
updateSkeleton :: OIdent -> HSkeleton -> (OIdent, [OIdent]) -> HSkeleton updateSkeleton :: OIdent -> HSkeleton -> (OIdent, [OIdent]) -> HSkeleton
updateSkeleton cat skel rule = updateSkeleton cat skel rule =
case skel of case skel of
(cat0,rules):rr | cat0 == cat -> (cat0, rule:rules) : rr (cat0,rules):rr | cat0 == cat -> (cat0, rule:rules) : rr
(cat0,rules):rr -> (cat0, rules) : updateSkeleton cat rr rule (cat0,rules):rr -> (cat0, rules) : updateSkeleton cat rr rule
-}
isListCat :: (OIdent, [(OIdent, [OIdent])]) -> Bool isListCat :: (OIdent, [(OIdent, [OIdent])]) -> Bool
isListCat (cat,rules) = "List" `isPrefixOf` cat && length rules == 2 isListCat (cat,rules) = "List" `isPrefixOf` cat && length rules == 2
&& ("Base"++c) `elem` fs && ("Cons"++c) `elem` fs && ("Base"++c) `elem` fs && ("Cons"++c) `elem` fs
@@ -289,13 +289,13 @@ isListCat (cat,rules) = "List" `isPrefixOf` cat && length rules == 2
-- | Gets the element category of a list category. -- | Gets the element category of a list category.
elemCat :: OIdent -> OIdent elemCat :: OIdent -> OIdent
elemCat = drop 4 elemCat = drop 4
{-
isBaseFun :: OIdent -> Bool isBaseFun :: OIdent -> Bool
isBaseFun f = "Base" `isPrefixOf` f isBaseFun f = "Base" `isPrefixOf` f
isConsFun :: OIdent -> Bool isConsFun :: OIdent -> Bool
isConsFun f = "Cons" `isPrefixOf` f isConsFun f = "Cons" `isPrefixOf` f
-}
baseSize :: (OIdent, [(OIdent, [OIdent])]) -> Int baseSize :: (OIdent, [(OIdent, [OIdent])]) -> Int
baseSize (_,rules) = length bs baseSize (_,rules) = length bs
where Just (_,bs) = find (("Base" `isPrefixOf`) . fst) rules where Just (_,bs) = find (("Base" `isPrefixOf`) . fst) rules

View File

@@ -51,11 +51,14 @@ concrete2js (c,cnc) =
JS.EInt (totalCats cnc)]) JS.EInt (totalCats cnc)])
where where
l = JS.IdentPropName (JS.Ident (showCId c)) l = JS.IdentPropName (JS.Ident (showCId c))
{-
litslins = [JS.Prop (JS.StringPropName "Int") (JS.EFun [children] [JS.SReturn $ new "Arr" [JS.EIndex (JS.EVar children) (JS.EInt 0)]]), litslins = [JS.Prop (JS.StringPropName "Int") (JS.EFun [children] [JS.SReturn $ new "Arr" [JS.EIndex (JS.EVar children) (JS.EInt 0)]]),
JS.Prop (JS.StringPropName "Float") (JS.EFun [children] [JS.SReturn $ new "Arr" [JS.EIndex (JS.EVar children) (JS.EInt 0)]]), JS.Prop (JS.StringPropName "Float") (JS.EFun [children] [JS.SReturn $ new "Arr" [JS.EIndex (JS.EVar children) (JS.EInt 0)]]),
JS.Prop (JS.StringPropName "String") (JS.EFun [children] [JS.SReturn $ new "Arr" [JS.EIndex (JS.EVar children) (JS.EInt 0)]])] JS.Prop (JS.StringPropName "String") (JS.EFun [children] [JS.SReturn $ new "Arr" [JS.EIndex (JS.EVar children) (JS.EInt 0)]])]
-}
cats (c,CncCat start end _) = JS.Prop (JS.IdentPropName (JS.Ident (showCId c))) (JS.EObj [JS.Prop (JS.IdentPropName (JS.Ident "s")) (JS.EInt start) cats (c,CncCat start end _) = JS.Prop (JS.IdentPropName (JS.Ident (showCId c))) (JS.EObj [JS.Prop (JS.IdentPropName (JS.Ident "s")) (JS.EInt start)
,JS.Prop (JS.IdentPropName (JS.Ident "e")) (JS.EInt end)]) ,JS.Prop (JS.IdentPropName (JS.Ident "e")) (JS.EInt end)])
{-
mkStr :: String -> JS.Expr mkStr :: String -> JS.Expr
mkStr s = new "Str" [JS.EStr s] mkStr s = new "Str" [JS.EStr s]
@@ -65,7 +68,7 @@ mkSeq xs = new "Seq" xs
argIdent :: Integer -> JS.Ident argIdent :: Integer -> JS.Ident
argIdent n = JS.Ident ("x" ++ show n) argIdent n = JS.Ident ("x" ++ show n)
-}
children :: JS.Ident children :: JS.Ident
children = JS.Ident "cs" children = JS.Ident "cs"

View File

@@ -479,7 +479,7 @@ checkLType gr g trm typ0 = do
R r -> case typ of --- why needed? because inference may be too difficult R r -> case typ of --- why needed? because inference may be too difficult
RecType rr -> do RecType rr -> do
let (ls,_) = unzip rr -- labels of expected type --let (ls,_) = unzip rr -- labels of expected type
fsts <- mapM (checkM r) rr -- check that they are found in the record fsts <- mapM (checkM r) rr -- check that they are found in the record
return $ (R fsts, typ) -- normalize record return $ (R fsts, typ) -- normalize record
@@ -556,10 +556,10 @@ checkLType gr g trm typ0 = do
termWith trm' $ checkEqLType gr g typ ty' trm' termWith trm' $ checkEqLType gr g typ ty' trm'
where where
justCheck g ty te = checkLType gr g ty te >>= return . fst justCheck g ty te = checkLType gr g ty te >>= return . fst
{-
recParts rr t = (RecType rr1,RecType rr2) where recParts rr t = (RecType rr1,RecType rr2) where
(rr1,rr2) = partition (flip elem (map fst t) . fst) rr (rr1,rr2) = partition (flip elem (map fst t) . fst) rr
-}
checkM rms (l,ty) = case lookup l rms of checkM rms (l,ty) = case lookup l rms of
Just (Just ty0,t) -> do Just (Just ty0,t) -> do
checkEqLType gr g ty ty0 t checkEqLType gr g ty ty0 t
@@ -747,12 +747,12 @@ ppType ty =
_ -> ppTerm Unqualified 0 ty _ -> ppTerm Unqualified 0 ty
Prod _ x a b -> ppType a <+> "->" <+> ppType b Prod _ x a b -> ppType a <+> "->" <+> ppType b
_ -> ppTerm Unqualified 0 ty _ -> ppTerm Unqualified 0 ty
{-
ppqType :: Type -> Type -> Doc ppqType :: Type -> Type -> Doc
ppqType t u = case (ppType t, ppType u) of ppqType t u = case (ppType t, ppType u) of
(pt,pu) | render pt == render pu -> ppTerm Qualified 0 t (pt,pu) | render pt == render pu -> ppTerm Qualified 0 t
(pt,_) -> pt (pt,_) -> pt
-}
checkLookup :: Ident -> Context -> Check Type checkLookup :: Ident -> Context -> Check Type
checkLookup x g = checkLookup x g =
case [ty | (b,y,ty) <- g, x == y] of case [ty | (b,y,ty) <- g, x == y] of

View File

@@ -64,8 +64,8 @@ lookupVar g x = maybe (Bad (render ("unknown variable" <+> x))) return $ lookup
type TCEnv = (Int,Env,Env) type TCEnv = (Int,Env,Env)
emptyTCEnv :: TCEnv --emptyTCEnv :: TCEnv
emptyTCEnv = (0,[],[]) --emptyTCEnv = (0,[],[])
whnf :: Val -> Err Val whnf :: Val -> Err Val
whnf v = ---- errIn ("whnf" +++ prt v) $ ---- debug whnf v = ---- errIn ("whnf" +++ prt v) $ ---- debug

View File

@@ -90,7 +90,7 @@ compileCFFiles opts fs = do
(CFRule cat _ _ : _) -> return cat (CFRule cat _ _ : _) -> return cat
_ -> fail "empty CFG" _ -> fail "empty CFG"
let pgf = cf2pgf (last fs) (uniqueFuns (mkCFG startCat Set.empty rules)) let pgf = cf2pgf (last fs) (uniqueFuns (mkCFG startCat Set.empty rules))
let cnc = justModuleName (last fs) --let cnc = justModuleName (last fs)
unless (flag optStopAfterPhase opts == Compile) $ unless (flag optStopAfterPhase opts == Compile) $
do probs <- liftIO (maybe (return . defaultProbabilities) readProbabilitiesFromFile (flag optProbsFile opts) pgf) do probs <- liftIO (maybe (return . defaultProbabilities) readProbabilitiesFromFile (flag optProbsFile opts) pgf)
let pgf' = setProbabilities probs $ if flag optOptimizePGF opts then optimizePGF pgf else pgf let pgf' = setProbabilities probs $ if flag optOptimizePGF opts then optimizePGF pgf else pgf

View File

@@ -189,5 +189,5 @@ remove x r = let (mss,r') = Map.updateLookupWithKey (\_ _ -> Nothing) x r
incoming :: Ord a => a -> Rel' a -> Set a incoming :: Ord a => a -> Rel' a -> Set a
incoming x r = maybe Set.empty fst $ Map.lookup x r incoming x r = maybe Set.empty fst $ Map.lookup x r
outgoing :: Ord a => a -> Rel' a -> Set a --outgoing :: Ord a => a -> Rel' a -> Set a
outgoing x r = maybe Set.empty snd $ Map.lookup x r --outgoing x r = maybe Set.empty snd $ Map.lookup x r

View File

@@ -20,8 +20,8 @@ module GF.Data.Str (
allItems allItems
) where ) where
import GF.Data.Operations import GF.Data.Operations(prQuotedString)
import Data.List (isPrefixOf, isSuffixOf, intersperse) import Data.List (isPrefixOf, intersperse) --, isSuffixOf
-- | abstract token list type. AR 2001, revised and simplified 20\/4\/2003 -- | abstract token list type. AR 2001, revised and simplified 20\/4\/2003
newtype Str = Str [Tok] deriving (Read, Show, Eq, Ord) newtype Str = Str [Tok] deriving (Read, Show, Eq, Ord)
@@ -50,11 +50,11 @@ matchPrefix s vs t =
(u,as) <- vs, (u,as) <- vs,
any (\c -> isPrefixOf c (concat (unmarkup t))) as any (\c -> isPrefixOf c (concat (unmarkup t))) as
] ++ [s] ] ++ [s]
{-
matchSuffix :: String -> Ss -> [(Ss,[String])] -> Ss matchSuffix :: String -> Ss -> [(Ss,[String])] -> Ss
matchSuffix t s vs = matchSuffix t s vs =
head ([u | (u,as) <- vs, any (\c -> isSuffixOf c t) as] ++ [s]) head ([u | (u,as) <- vs, any (\c -> isSuffixOf c t) as] ++ [s])
-}
unmarkup :: [String] -> [String] unmarkup :: [String] -> [String]
unmarkup = filter (not . isXMLtag) where unmarkup = filter (not . isXMLtag) where
isXMLtag s = case s of isXMLtag s = case s of

View File

@@ -119,22 +119,22 @@ sizeInfo i = case i of
msize mt = case mt of msize mt = case mt of
Just (L _ t) -> sizeTerm t Just (L _ t) -> sizeTerm t
_ -> 0 _ -> 0
{-
-- the size of a module -- the size of a module
sizeModule :: SourceModule -> Int sizeModule :: SourceModule -> Int
sizeModule = fst . sizesModule sizeModule = fst . sizesModule
-}
sizesModule :: SourceModule -> (Int, [(Ident,Int)]) sizesModule :: SourceModule -> (Int, [(Ident,Int)])
sizesModule (_,m) = sizesModule (_,m) =
let let
js = Map.toList (jments m) js = Map.toList (jments m)
tb = [(i,k) | (i,j) <- js, let k = sizeInfo j, k >= 0] tb = [(i,k) | (i,j) <- js, let k = sizeInfo j, k >= 0]
in (length tb + sum (map snd tb),tb) in (length tb + sum (map snd tb),tb)
{-
-- the size of a grammar -- the size of a grammar
sizeGrammar :: Grammar -> Int sizeGrammar :: Grammar -> Int
sizeGrammar = fst . sizesGrammar sizeGrammar = fst . sizesGrammar
-}
sizesGrammar :: Grammar -> (Int,[(ModuleName,(Int,[(Ident,Int)]))]) sizesGrammar :: Grammar -> (Int,[(ModuleName,(Int,[(Ident,Int)]))])
sizesGrammar g = sizesGrammar g =
let let

View File

@@ -153,13 +153,13 @@ removeLeftRecursion gr
-- note: the rest don't occur in the original grammar -- note: the rest don't occur in the original grammar
cats = allCats gr cats = allCats gr
rules = allRules gr -- rules = allRules gr
directLeftCorner = mkRel [(NonTerminal c,t) | CFRule c (t:_) _ <- allRules gr] directLeftCorner = mkRel [(NonTerminal c,t) | CFRule c (t:_) _ <- allRules gr]
leftCorner = reflexiveClosure_ (map NonTerminal cats) $ transitiveClosure directLeftCorner -- leftCorner = reflexiveClosure_ (map NonTerminal cats) $ transitiveClosure directLeftCorner
properLeftCorner = transitiveClosure directLeftCorner properLeftCorner = transitiveClosure directLeftCorner
properLeftCornersOf = Set.toList . allRelated properLeftCorner . NonTerminal properLeftCornersOf = Set.toList . allRelated properLeftCorner . NonTerminal
isProperLeftCornerOf = flip (isRelatedTo properLeftCorner) -- isProperLeftCornerOf = flip (isRelatedTo properLeftCorner)
leftRecursive = reflexiveElements properLeftCorner leftRecursive = reflexiveElements properLeftCorner
isLeftRecursive = (`Set.member` leftRecursive) isLeftRecursive = (`Set.member` leftRecursive)
@@ -167,7 +167,7 @@ removeLeftRecursion gr
retained = cfgStartCat gr `Set.insert` retained = cfgStartCat gr `Set.insert`
Set.fromList [a | r <- allRules (filterCFGCats (not . isLeftRecursive . NonTerminal) gr), Set.fromList [a | r <- allRules (filterCFGCats (not . isLeftRecursive . NonTerminal) gr),
NonTerminal a <- ruleRhs r] NonTerminal a <- ruleRhs r]
isRetained = (`Set.member` retained) -- isRetained = (`Set.member` retained)
retainedLeftRecursive = filter (isLeftRecursive . NonTerminal) $ Set.toList retained retainedLeftRecursive = filter (isLeftRecursive . NonTerminal) $ Set.toList retained

View File

@@ -49,9 +49,9 @@ normEBNF erules = let
erules1 = [normERule ([i],r) | (i,r) <- zip [0..] erules] erules1 = [normERule ([i],r) | (i,r) <- zip [0..] erules]
erules2 = erules1 ---refreshECats erules1 --- this seems to be just bad ! erules2 = erules1 ---refreshECats erules1 --- this seems to be just bad !
erules3 = concat (map pickERules erules2) erules3 = concat (map pickERules erules2)
erules4 = nubERules erules3 --erules4 = nubERules erules3
in [(mkCFCatE cat, map eitem2cfitem its) | (cat,itss) <- erules3, its <- itss] in [(mkCFCatE cat, map eitem2cfitem its) | (cat,itss) <- erules3, its <- itss]
{-
refreshECats :: [NormERule] -> [NormERule] refreshECats :: [NormERule] -> [NormERule]
refreshECats rules = [recas [i] rule | (i,rule) <- zip [0..] rules] where refreshECats rules = [recas [i] rule | (i,rule) <- zip [0..] rules] where
recas ii (cat,its) = (updECat ii cat, [recss ii 0 s | s <- its]) recas ii (cat,its) = (updECat ii cat, [recss ii 0 s | s <- its])
@@ -63,7 +63,7 @@ refreshECats rules = [recas [i] rule | (i,rule) <- zip [0..] rules] where
EIPlus (cat,t) -> EIPlus (updECat ii cat, [recss ii 0 s | s <- t]) EIPlus (cat,t) -> EIPlus (updECat ii cat, [recss ii 0 s | s <- t])
EIOpt (cat,t) -> EIOpt (updECat ii cat, [recss ii 0 s | s <- t]) EIOpt (cat,t) -> EIOpt (updECat ii cat, [recss ii 0 s | s <- t])
_ -> it _ -> it
-}
pickERules :: NormERule -> [NormERule] pickERules :: NormERule -> [NormERule]
pickERules rule@(cat,alts) = rule : concat (map pics (concat alts)) where pickERules rule@(cat,alts) = rule : concat (map pics (concat alts)) where
pics it = case it of pics it = case it of
@@ -77,7 +77,7 @@ pickERules rule@(cat,alts) = rule : concat (map pics (concat alts)) where
where cat' = mkNewECat cat "Plus" where cat' = mkNewECat cat "Plus"
mkEOptRules cat = [(cat', [[],[EINonTerm cat]])] mkEOptRules cat = [(cat', [[],[EINonTerm cat]])]
where cat' = mkNewECat cat "Opt" where cat' = mkNewECat cat "Opt"
{-
nubERules :: [NormERule] -> [NormERule] nubERules :: [NormERule] -> [NormERule]
nubERules rules = nub optim where nubERules rules = nub optim where
optim = map (substERules (map mkSubst replaces)) irreducibles optim = map (substERules (map mkSubst replaces)) irreducibles
@@ -100,7 +100,7 @@ substERules g (cat,itss) = (cat, map sub itss) where
sub (EIStar r : ii) = EIStar (substERules g r) : ii sub (EIStar r : ii) = EIStar (substERules g r) : ii
sub (EIPlus r : ii) = EIPlus (substERules g r) : ii sub (EIPlus r : ii) = EIPlus (substERules g r) : ii
sub (EIOpt r : ii) = EIOpt (substERules g r) : ii sub (EIOpt r : ii) = EIOpt (substERules g r) : ii
-}
eitem2cfitem :: EItem -> CFSymbol eitem2cfitem :: EItem -> CFSymbol
eitem2cfitem it = case it of eitem2cfitem it = case it of
EITerm a -> Terminal a EITerm a -> Terminal a
@@ -145,8 +145,8 @@ prECat (c,ints) = c ++ "_" ++ prTList "_" (map show ints)
mkCFCatE :: ECat -> Cat mkCFCatE :: ECat -> Cat
mkCFCatE = prECat mkCFCatE = prECat
{-
updECat _ (c,[]) = (c,[]) updECat _ (c,[]) = (c,[])
updECat ii (c,_) = (c,ii) updECat ii (c,_) = (c,ii)
-}
mkNewECat (c,ii) str = (c ++ str,ii) mkNewECat (c,ii) str = (c ++ str,ii)

View File

@@ -190,9 +190,9 @@ allExtendsPlus gr i =
where where
exts m = extends m ++ [j | MTInstance (j,_) <- [mtype m]] exts m = extends m ++ [j | MTInstance (j,_) <- [mtype m]]
-- | initial search path: the nonqualified dependencies -- -- | initial search path: the nonqualified dependencies
searchPathModule :: ModuleInfo -> [ModuleName] -- searchPathModule :: ModuleInfo -> [ModuleName]
searchPathModule m = [i | OSimple i <- depPathModule m] -- searchPathModule m = [i | OSimple i <- depPathModule m]
prependModule :: Grammar -> Module -> Grammar prependModule :: Grammar -> Module -> Grammar
prependModule (MGrammar mm ms) im@(i,m) = MGrammar (Map.insert i m mm) (im:ms) prependModule (MGrammar mm ms) im@(i,m) = MGrammar (Map.insert i m mm) (im:ms)

View File

@@ -201,7 +201,7 @@ varsOfPatt p = case p of
PR r -> concat $ map (varsOfPatt . snd) r PR r -> concat $ map (varsOfPatt . snd) r
PT _ q -> varsOfPatt q PT _ q -> varsOfPatt q
_ -> [] _ -> []
-}
-- | to search matching parameter combinations in tables -- | to search matching parameter combinations in tables
isMatchingForms :: [Patt] -> [Term] -> Bool isMatchingForms :: [Patt] -> [Term] -> Bool
isMatchingForms ps ts = all match (zip ps ts') where isMatchingForms ps ts = all match (zip ps ts') where
@@ -209,3 +209,4 @@ isMatchingForms ps ts = all match (zip ps ts') where
match _ = True match _ = True
ts' = map appForm ts ts' = map appForm ts
-}

View File

@@ -22,7 +22,7 @@ render d = rend 0 (map ($ "") $ d []) "" where
t:ts@(t':_) | not (spaceBefore t') -> showString t . rend i ts t:ts@(t':_) | not (spaceBefore t') -> showString t . rend i ts
t:ts -> space t . rend i ts t:ts -> space t . rend i ts
[] -> id [] -> id
new i = showChar '\n' . replicateS (2*i) (showChar ' ') . dropWhile isSpace --new i = showChar '\n' . replicateS (2*i) (showChar ' ') . dropWhile isSpace
space t = showString t . (\s -> if null s then "" else (' ':s)) space t = showString t . (\s -> if null s then "" else (' ':s))
spaceAfter :: String -> Bool spaceAfter :: String -> Bool
@@ -39,10 +39,10 @@ concatS = foldr (.) id
concatD :: [Doc] -> Doc concatD :: [Doc] -> Doc
concatD = foldr (.) id concatD = foldr (.) id
{-
replicateS :: Int -> ShowS -> ShowS replicateS :: Int -> ShowS -> ShowS
replicateS n f = concatS (replicate n f) replicateS n f = concatS (replicate n f)
-}
-- the printer class does the job -- the printer class does the job
class Print a where class Print a where
prt :: Int -> a -> Doc prt :: Int -> a -> Doc

View File

@@ -142,7 +142,7 @@ handle logLn documentroot state0 cache execute1 stateVar
_ -> return (resp501 $ "method "++method) _ -> return (resp501 $ "method "++method)
where where
logPutStrLn msg = liftIO $ logLn msg logPutStrLn msg = liftIO $ logLn msg
debug msg = logPutStrLn msg -- debug msg = logPutStrLn msg
addDate m = addDate m =
do t <- getCurrentTime do t <- getCurrentTime
@@ -371,7 +371,7 @@ ok200' t = Response 200 [t,xo]
json200 x = json200' id x json200 x = json200' id x
json200' f = ok200' jsonUTF8 . encodeString . f . encode json200' f = ok200' jsonUTF8 . encodeString . f . encode
jsonp200' f = ok200' jsonpUTF8 . encodeString . f . encode jsonp200' f = ok200' jsonpUTF8 . encodeString . f . encode
html200 = ok200' htmlUTF8 . encodeString --html200 = ok200' htmlUTF8 . encodeString
resp204 = Response 204 [xo] "" -- no content resp204 = Response 204 [xo] "" -- no content
resp301 url = Response 301 [plain,xo,location url] $ resp301 url = Response 301 [plain,xo,location url] $
"Moved permanently to "++url "Moved permanently to "++url
@@ -389,7 +389,7 @@ plain = ct "text/plain" ""
plainUTF8 = ct "text/plain" csutf8 plainUTF8 = ct "text/plain" csutf8
jsonUTF8 = ct "application/json" csutf8 -- http://www.ietf.org/rfc/rfc4627.txt jsonUTF8 = ct "application/json" csutf8 -- http://www.ietf.org/rfc/rfc4627.txt
jsonpUTF8 = ct "application/javascript" csutf8 jsonpUTF8 = ct "application/javascript" csutf8
htmlUTF8 = ct "text/html" csutf8 --htmlUTF8 = ct "text/html" csutf8
ct t cs = ("Content-Type",t++cs) ct t cs = ("Content-Type",t++cs)
csutf8 = "; charset=UTF-8" csutf8 = "; charset=UTF-8"

View File

@@ -36,7 +36,7 @@ module GF.Speech.FiniteState (FA(..), State, NFA, DFA,
import Data.List import Data.List
import Data.Maybe import Data.Maybe
import Data.Map (Map) --import Data.Map (Map)
import qualified Data.Map as Map import qualified Data.Map as Map
import Data.Set (Set) import Data.Set (Set)
import qualified Data.Set as Set import qualified Data.Set as Set
@@ -246,8 +246,8 @@ fixIncoming cs c@((n,()),es) = (cs'', ((n,Nothing),es'):newContexts)
++ [ (y,x,()) | (f,_,l') <- cyc, l == l', (y,_) <- newNodes] ++ [ (y,x,()) | (f,_,l') <- cyc, l == l', (y,_) <- newNodes]
newContexts = [ (v, to v) | v <- newNodes ] newContexts = [ (v, to v) | v <- newNodes ]
alphabet :: Eq b => Graph n a (Maybe b) -> [b] --alphabet :: Eq b => Graph n a (Maybe b) -> [b]
alphabet = nub . catMaybes . map edgeLabel . edges --alphabet = nub . catMaybes . map edgeLabel . edges
determinize :: Ord a => NFA a -> DFA a determinize :: Ord a => NFA a -> DFA a
determinize (FA g s f) = let (ns,es) = h (Set.singleton start) Set.empty Set.empty determinize (FA g s f) = let (ns,es) = h (Set.singleton start) Set.empty Set.empty
@@ -309,8 +309,8 @@ dfa2nfa = mapTransitions Just
prFAGraphviz :: (Eq n,Show n) => FA n String String -> String prFAGraphviz :: (Eq n,Show n) => FA n String String -> String
prFAGraphviz = Dot.prGraphviz . faToGraphviz prFAGraphviz = Dot.prGraphviz . faToGraphviz
prFAGraphviz_ :: (Eq n,Show n,Show a, Show b) => FA n a b -> String --prFAGraphviz_ :: (Eq n,Show n,Show a, Show b) => FA n a b -> String
prFAGraphviz_ = Dot.prGraphviz . faToGraphviz . mapStates show . mapTransitions show --prFAGraphviz_ = Dot.prGraphviz . faToGraphviz . mapStates show . mapTransitions show
faToGraphviz :: (Eq n,Show n) => FA n String String -> Dot.Graph faToGraphviz :: (Eq n,Show n) => FA n String String -> Dot.Graph
faToGraphviz (FA (Graph _ ns es) s f) faToGraphviz (FA (Graph _ ns es) s f)
@@ -325,5 +325,5 @@ faToGraphviz (FA (Graph _ ns es) s f)
-- * Utilities -- * Utilities
-- --
lookups :: Ord k => [k] -> Map k a -> [a] --lookups :: Ord k => [k] -> Map k a -> [a]
lookups xs m = mapMaybe (flip Map.lookup m) xs --lookups xs m = mapMaybe (flip Map.lookup m) xs

View File

@@ -78,8 +78,8 @@ keepSymbol _ = True
showToken :: Token -> Doc showToken :: Token -> Doc
showToken = pp . map toLower showToken = pp . map toLower
isPunct :: Char -> Bool --isPunct :: Char -> Bool
isPunct c = c `elem` "-_.:;.,?!()[]{}" --isPunct c = c `elem` "-_.:;.,?!()[]{}"
comment :: String -> Doc comment :: String -> Doc
comment s = ";" <+> s comment s = ";" <+> s

View File

@@ -51,7 +51,7 @@ mkFAs pgf cnc = (slfStyleFA main, [(c,slfStyleFA n) | (c,n) <- subs])
slfStyleFA :: Eq a => DFA a -> FA State (Maybe a) () slfStyleFA :: Eq a => DFA a -> FA State (Maybe a) ()
slfStyleFA = renameStates [0..] . removeTrivialEmptyNodes . oneFinalState Nothing () slfStyleFA = renameStates [0..] . removeTrivialEmptyNodes . oneFinalState Nothing ()
. moveLabelsToNodes . dfa2nfa . moveLabelsToNodes . dfa2nfa
{-
-- | Give sequential names to subnetworks. -- | Give sequential names to subnetworks.
renameSubs :: MFA -> MFA renameSubs :: MFA -> MFA
renameSubs (MFA start subs) = MFA (newName start) subs' renameSubs (MFA start subs) = MFA (newName start) subs'
@@ -59,7 +59,7 @@ renameSubs (MFA start subs) = MFA (newName start) subs'
newName s = lookup' s newNames newName s = lookup' s newNames
subs' = [(newName s,renameLabels n) | (s,n) <- subs] subs' = [(newName s,renameLabels n) | (s,n) <- subs]
renameLabels = mapTransitions (mapSymbol newName id) renameLabels = mapTransitions (mapSymbol newName id)
-}
-- --
-- * SLF graphviz printing (without sub-networks) -- * SLF graphviz printing (without sub-networks)
-- --

View File

@@ -37,7 +37,7 @@ import qualified Data.Map as Map
import Data.Set (Set) import Data.Set (Set)
import qualified Data.Set as Set import qualified Data.Set as Set
import Debug.Trace --import Debug.Trace
data SRG = SRG { srgName :: String -- ^ grammar name data SRG = SRG { srgName :: String -- ^ grammar name
, srgStartCat :: Cat -- ^ start category name , srgStartCat :: Cat -- ^ start category name
@@ -88,13 +88,13 @@ setDefaultCFGTransform opts t b = setCFGTransform t b `addOptions` opts
maybeTransform :: Options -> CFGTransform -> (CFG -> CFG) -> (CFG -> CFG) maybeTransform :: Options -> CFGTransform -> (CFG -> CFG) -> (CFG -> CFG)
maybeTransform opts t f = if cfgTransform opts t then f else id maybeTransform opts t f = if cfgTransform opts t then f else id
{-
traceStats s g = trace ("---- " ++ s ++ ": " ++ stats g {- ++ "\n" ++ prCFRules g ++ "----" -}) g traceStats s g = trace ("---- " ++ s ++ ": " ++ stats g {- ++ "\n" ++ prCFRules g ++ "----" -}) g
stats g = "Categories: " ++ show (countCats g) stats g = "Categories: " ++ show (countCats g)
++ ", External categories: " ++ show (Set.size (cfgExternalCats g)) ++ ", External categories: " ++ show (Set.size (cfgExternalCats g))
++ ", Rules: " ++ show (countRules g) ++ ", Rules: " ++ show (countRules g)
-}
makeNonRecursiveSRG :: Options makeNonRecursiveSRG :: Options
-> PGF -> PGF
-> CId -- ^ Concrete syntax name. -> CId -- ^ Concrete syntax name.

View File

@@ -99,10 +99,10 @@ tag (Just fmt) t =
isPunct :: Char -> Bool isPunct :: Char -> Bool
isPunct c = c `elem` "-_.;.,?!" isPunct c = c `elem` "-_.;.,?!"
{-
comment :: String -> Doc comment :: String -> Doc
comment s = "//" <+> s comment s = "//" <+> s
-}
alts :: [Doc] -> Doc alts :: [Doc] -> Doc
alts = fsep . prepunctuate ("| ") alts = fsep . prepunctuate ("| ")

View File

@@ -151,13 +151,13 @@ prompt = Tag "prompt" []
promptString :: String -> XML promptString :: String -> XML
promptString p = prompt [Data p] promptString p = prompt [Data p]
{-
reprompt :: XML reprompt :: XML
reprompt = ETag "reprompt" [] reprompt = ETag "reprompt" []
-}
assign :: String -> String -> XML assign :: String -> String -> XML
assign n e = ETag "assign" [("name",n),("expr",e)] assign n e = ETag "assign" [("name",n),("expr",e)]
{-
value :: String -> XML value :: String -> XML
value expr = ETag "value" [("expr",expr)] value expr = ETag "value" [("expr",expr)]
@@ -174,7 +174,7 @@ cond ((c,b):rest) els = Tag "if" [("cond",c)] (b ++ es)
goto_item :: String -> XML goto_item :: String -> XML
goto_item nextitem = ETag "goto" [("nextitem",nextitem)] goto_item nextitem = ETag "goto" [("nextitem",nextitem)]
-}
return_ :: [String] -> XML return_ :: [String] -> XML
return_ names = ETag "return" [("namelist", unwords names)] return_ names = ETag "return" [("namelist", unwords names)]
@@ -183,7 +183,7 @@ block = Tag "block" []
blockCond :: String -> [XML] -> XML blockCond :: String -> [XML] -> XML
blockCond cond = Tag "block" [("cond", cond)] blockCond cond = Tag "block" [("cond", cond)]
{-
throw :: String -> String -> XML throw :: String -> String -> XML
throw event msg = Tag "throw" [("event",event),("message",msg)] [] throw event msg = Tag "throw" [("event",event),("message",msg)] []
@@ -192,20 +192,20 @@ nomatch = Tag "nomatch" []
help :: [XML] -> XML help :: [XML] -> XML
help = Tag "help" [] help = Tag "help" []
-}
param :: String -> String -> XML param :: String -> String -> XML
param name expr = ETag "param" [("name",name),("expr",expr)] param name expr = ETag "param" [("name",name),("expr",expr)]
var :: String -> Maybe String -> XML var :: String -> Maybe String -> XML
var name expr = ETag "var" ([("name",name)]++e) var name expr = ETag "var" ([("name",name)]++e)
where e = maybe [] ((:[]) . (,) "expr") expr where e = maybe [] ((:[]) . (,) "expr") expr
{-
script :: String -> XML script :: String -> XML
script s = Tag "script" [] [CData s] script s = Tag "script" [] [CData s]
scriptURI :: String -> XML scriptURI :: String -> XML
scriptURI uri = Tag "script" [("uri", uri)] [] scriptURI uri = Tag "script" [("uri", uri)] []
-}
-- --
-- * ECMAScript stuff -- * ECMAScript stuff
-- --

View File

@@ -35,6 +35,6 @@ getCliticsText isLex rclitics =
-- example -- example
getClitics1 = getClitics exlex1 exclits1 --getClitics1 = getClitics exlex1 exclits1
exlex1 = flip elem ["auto", "naise", "rahan","maa","maahan","maahankaan"] --exlex1 = flip elem ["auto", "naise", "rahan","maa","maahan","maahankaan"]
exclits1 = map reverse ["ni","ko","han","pas","nsa","kin","kaan"] --exclits1 = map reverse ["ni","ko","han","pas","nsa","kin","kaan"]

View File

@@ -92,7 +92,7 @@ llin :: Environ -> Expr -> Expr
llin env expr = llin env expr =
let let
(id,args) = fromJust $ unApp expr (id,args) = fromJust $ unApp expr
cexpr = fromJust $ Map.lookup id (getConcMap env) --cexpr = fromJust $ Map.lookup id (getConcMap env)
in in
if any isMeta args if any isMeta args
then let then let
@@ -170,7 +170,7 @@ embedInStart fss cs =
----------------------------------------------- -----------------------------------------------
{-
updateConcMap :: Environ -> MyFunc -> Expr -> Environ updateConcMap :: Environ -> MyFunc -> Expr -> Environ
updateConcMap env myf expr = updateConcMap env myf expr =
Env (getTypeMap env) (Map.insert myf expr (getConcMap env)) (getSigs env) (getAll env) Env (getTypeMap env) (Map.insert myf expr (getConcMap env)) (getSigs env) (getAll env)
@@ -196,14 +196,14 @@ updateEnv env myf myt expr =
newInterInstr = newInterInstr =
maybe (Map.insert myt [myf] ii) (\x -> Map.insert myt (myf:x) ii) $ Map.lookup myt ii maybe (Map.insert myt [myf] ii) (\x -> Map.insert myt (myf:x) ii) $ Map.lookup myt ii
in Env (getTypeMap env) (Map.insert nn expr (getConcMap env)) newInterInstr (getAll env) in Env (getTypeMap env) (Map.insert nn expr (getConcMap env)) newInterInstr (getAll env)
-}
mkSigs :: [FuncWithArg] -> Map.Map MyType [FuncWithArg] mkSigs :: [FuncWithArg] -> Map.Map MyType [FuncWithArg]
mkSigs fss = Map.fromListWith (++) $ zip (map getType fss) (map (\x -> [x]) fss) mkSigs fss = Map.fromListWith (++) $ zip (map getType fss) (map (\x -> [x]) fss)
------------------------------------ {------------------------------------
lang :: String lang :: String
lang = "Eng" lang = "Eng"
@@ -214,7 +214,7 @@ parseLang = fromJust $ readLanguage "ParseEng"
parsePGFfile :: String parsePGFfile :: String
parsePGFfile = "ParseEngAbs.pgf" parsePGFfile = "ParseEngAbs.pgf"
------------------------------------ ------------------------------------}
@@ -307,7 +307,7 @@ debugReplaceConc expr i e =
in (mkApp cid (map fst repargs), or $ map snd repargs)) $ unApp e_ in (mkApp cid (map fst repargs), or $ map snd repargs)) $ unApp e_
{-
-- replaceArgs : Original expression to parse (from abstract syntax) -> Concrete expression (parsed) -- replaceArgs : Original expression to parse (from abstract syntax) -> Concrete expression (parsed)
replaceArgs :: Expr -> Expr -> Environ -> Maybe Expr replaceArgs :: Expr -> Expr -> Environ -> Maybe Expr
replaceArgs aexpr cexpr env = replaceArgs aexpr cexpr env =
@@ -352,7 +352,7 @@ simpleReplace :: String -> String
simpleReplace [] = [] simpleReplace [] = []
simpleReplace ('?':xs) = 'o' : simpleReplace xs simpleReplace ('?':xs) = 'o' : simpleReplace xs
simpleReplace (x:xs) = x : simpleReplace xs simpleReplace (x:xs) = x : simpleReplace xs
-}
isMeta :: Expr -> Bool isMeta :: Expr -> Bool
isMeta = isJust.unMeta isMeta = isJust.unMeta
@@ -368,12 +368,12 @@ mkFuncWithArg ((c1,c2),cids) = FuncWithArg c1 c2 cids
initial :: TypeMap -> ConcMap -> [FuncWithArg] -> [FuncWithArg] -> Environ initial :: TypeMap -> ConcMap -> [FuncWithArg] -> [FuncWithArg] -> Environ
initial tm cm fss allfs = Env tm cm (mkSigs fss) allfs initial tm cm fss allfs = Env tm cm (mkSigs fss) allfs
{-
testInit :: [FuncWithArg] -> Environ testInit :: [FuncWithArg] -> Environ
testInit allfs = initial lTypes Map.empty [] allfs testInit allfs = initial lTypes Map.empty [] allfs
lTypes = Map.fromList [(mkCId "Comment", mkCId "S"),(mkCId "Item", mkCId "NP"), (mkCId "Kind", mkCId "CN"), (mkCId "Quality", mkCId "AP")] lTypes = Map.fromList [(mkCId "Comment", mkCId "S"),(mkCId "Item", mkCId "NP"), (mkCId "Kind", mkCId "CN"), (mkCId "Quality", mkCId "AP")]
-}
startCateg = mkCId "Comment" startCateg = mkCId "Comment"
-- question about either to give the startcat or not ... -- question about either to give the startcat or not ...

View File

@@ -71,11 +71,11 @@ doTestFunction cwd cache environ =
getCId :: String -> CGI CId getCId :: String -> CGI CId
getCId name = maybe err return =<< fmap readCId (getInp name) getCId name = maybe err return =<< fmap readCId (getInp name)
where err = throwCGIError 400 ("Bad "++name) [] where err = throwCGIError 400 ("Bad "++name) []
{-
getLimit :: CGI Int getLimit :: CGI Int
getLimit = maybe err return =<< readInput "limit" getLimit = maybe err return =<< readInput "limit"
where err = throwCGIError 400 "Missing/bad limit" [] where err = throwCGIError 400 "Missing/bad limit" []
-}
readParsePGF cwd cache = readParsePGF cwd cache =
do parsepgf <- getInp "parser" do parsepgf <- getInp "parser"

View File

@@ -71,7 +71,7 @@ bracketedTokn dp f@(Forest abs cnc forest root) =
in (ct,fid',fun,es,(map getVar hypos,lin)) in (ct,fid',fun,es,(map getVar hypos,lin))
Nothing -> error ("wrong forest id " ++ show fid) Nothing -> error ("wrong forest id " ++ show fid)
where where
descend forest (PApply funid args) = let (CncFun fun lins) = cncfuns cnc ! funid descend forest (PApply funid args) = let (CncFun fun _lins) = cncfuns cnc ! funid
cat = case isLindefCId fun of cat = case isLindefCId fun of
Just cat -> cat Just cat -> cat
Nothing -> case Map.lookup fun (funs abs) of Nothing -> case Map.lookup fun (funs abs) of
@@ -132,7 +132,7 @@ getAbsTrees (Forest abs cnc forest root) arg@(PArg _ fid) ty dp =
| otherwise = do fid0 <- get | otherwise = do fid0 <- get
put fid put fid
x <- foldForest (\funid args trees -> x <- foldForest (\funid args trees ->
do let CncFun fn lins = cncfuns cnc ! funid do let CncFun fn _lins = cncfuns cnc ! funid
case isLindefCId fn of case isLindefCId fn of
Just _ -> do arg <- go (Set.insert fid rec_) scope mb_tty (head args) Just _ -> do arg <- go (Set.insert fid rec_) scope mb_tty (head args)
return (mkAbs arg) return (mkAbs arg)

View File

@@ -124,5 +124,5 @@ linTree pgf cnc e = nub (map snd (lin Nothing 0 e [] [] e []))
def (Just (cat,fid)) n_fid e0 ys xs s def (Just (cat,fid)) n_fid e0 ys xs s
def Nothing n_fid e0 ys xs s = [] def Nothing n_fid e0 ys xs s = []
amapWithIndex :: (IArray a e1, IArray a e2, Ix i) => (i -> e1 -> e2) -> a i e1 -> a i e2 --amapWithIndex :: (IArray a e1, IArray a e2, Ix i) => (i -> e1 -> e2) -> a i e1 -> a i e2
amapWithIndex f arr = listArray (bounds arr) (map (uncurry f) (assocs arr)) --amapWithIndex f arr = listArray (bounds arr) (map (uncurry f) (assocs arr))

View File

@@ -231,11 +231,11 @@ computeSeq filter seq args = concatMap compute seq
| otherwise = arg_lin | otherwise = arg_lin
where where
arg_lin = lin ! r arg_lin = lin ! r
(ct@(cat,fid),_,fun,es,(xs,lin)) = args !! d (ct@(cat,fid),_,fun,es,(_xs,lin)) = args !! d
getVar d r = [LeafKS (showCId (xs !! r))] getVar d r = [LeafKS (showCId (xs !! r))]
where where
(ct,_,fun,es,(xs,lin)) = args !! d (_ct,_,_fun,_es,(xs,_lin)) = args !! d
flattenBracketedString :: BracketedString -> [String] flattenBracketedString :: BracketedString -> [String]
flattenBracketedString (Leaf w) = [w] flattenBracketedString (Leaf w) = [w]

View File

@@ -159,8 +159,8 @@ getArray get1 = toArray `fmap` getList' get1
toArray (n,xs) = listArray (0::Int,n-1) xs toArray (n,xs) = listArray (0::Int,n-1) xs
listToArray xs = toArray (length xs,xs) listToArray xs = toArray (length xs,xs)
getArray2 :: (IArray a1 (a2 Int e), IArray a2 e) => Get e -> Get (a1 Int (a2 Int e)) --getArray2 :: (IArray a1 (a2 Int e), IArray a2 e) => Get e -> Get (a1 Int (a2 Int e))
getArray2 get1 = getArray (getArray get1) --getArray2 get1 = getArray (getArray get1)
getList get1 = snd `fmap` getList' get1 getList get1 = snd `fmap` getList' get1

View File

@@ -210,7 +210,7 @@ mkProbDefs pgf =
then closure k deps2 vs2 vs3 then closure k deps2 vs2 vs3
else closure k deps2 ((src,dst') : vs2) vs3 else closure k deps2 ((src,dst') : vs2) vs3
else closure k (dep2 : deps2) vs2 vs3 else closure k (dep2 : deps2) vs2 vs3
{-
mkNewSig src = mkNewSig src =
DTyp (mkArgs 0 0 [] src) cidFloat [] DTyp (mkArgs 0 0 [] src) cidFloat []
where where
@@ -219,7 +219,7 @@ mkProbDefs pgf =
| i == k = let ty = DTyp [] c (map (normalForm sig k env) es) | i == k = let ty = DTyp [] c (map (normalForm sig k env) es)
in (Explicit,wildCId,ty) : mkArgs (k+1) (l+1) (VGen l [] : env) src in (Explicit,wildCId,ty) : mkArgs (k+1) (l+1) (VGen l [] : env) src
| otherwise = mkArgs (k+1) l (VMeta 0 env [] : env) src | otherwise = mkArgs (k+1) l (VMeta 0 env [] : env) src
-}
type CState = (Int,Map.Map CId [Equation]) type CState = (Int,Map.Map CId [Equation])
computeConstrs :: PGF -> CState -> [(CId,[Patt],[Expr])] -> (CState,[[CId]]) computeConstrs :: PGF -> CState -> [(CId,[Patt],[Expr])] -> (CState,[[CId]])
@@ -263,7 +263,7 @@ computeConstrs pgf st fns =
where where
addArgs (cn,fns) = addArg (length args) cn [] fns addArgs (cn,fns) = addArg (length args) cn [] fns
where where
Just (ty@(DTyp args _ es),_,_,_) = Map.lookup cn (funs (abstract pgf)) Just (DTyp args _ _es,_,_,_) = Map.lookup cn (funs (abstract pgf))
addArg 0 cn ps fns = [(PApp cn (reverse ps),fns)] addArg 0 cn ps fns = [(PApp cn (reverse ps),fns)]
addArg n cn ps fns = concat [addArg (n-1) cn (arg:ps) fns' | (arg,fns') <- computeConstr fns] addArg n cn ps fns = concat [addArg (n-1) cn (arg:ps) fns' | (arg,fns') <- computeConstr fns]

View File

@@ -55,7 +55,7 @@ typesInterm abs fset =
in (x,c)) fset in (x,c)) fset
in Map.fromList $ Set.toList fsetTypes in Map.fromList $ Set.toList fsetTypes
{-
takeArgs :: Map.Map CId CId -> Map.Map CId Expr -> CId -> Expr takeArgs :: Map.Map CId CId -> Map.Map CId Expr -> CId -> Expr
takeArgs mtypes mexpr ty = takeArgs mtypes mexpr ty =
let xarg = head $ Map.keys $ Map.filter (==ty) mtypes let xarg = head $ Map.keys $ Map.filter (==ty) mtypes
@@ -63,7 +63,7 @@ takeArgs mtypes mexpr ty =
doesReturnCat :: Type -> CId -> Bool doesReturnCat :: Type -> CId -> Bool
doesReturnCat (DTyp _ c _) cat = c == cat doesReturnCat (DTyp _ c _) cat = c == cat
-}
returnCat :: Abstr -> CId -> CId returnCat :: Abstr -> CId -> CId
returnCat abs cid = returnCat abs cid =
let p = Map.lookup cid $ funs abs let p = Map.lookup cid $ funs abs

View File

@@ -600,6 +600,7 @@ generateForForest :: (Scope -> TType -> TcM FId Expr) -> Expr -> TcM FId Expr
generateForForest prove e = do generateForForest prove e = do
-- fillinVariables -- fillinVariables
refineExpr e refineExpr e
{-
where where
fillinVariables = do fillinVariables = do
fvs <- TcM (\abstr k h ms -> k [(i,s,scope,tty,cs) | (i,MUnbound s scope tty cs) <- IntMap.toList ms] ms) fvs <- TcM (\abstr k h ms -> k [(i,s,scope,tty,cs) | (i,MUnbound s scope tty cs) <- IntMap.toList ms] ms)
@@ -614,6 +615,7 @@ generateForForest prove e = do
sequence_ [c e | c <- cs] sequence_ [c e | c <- cs]
fillinVariables fillinVariables
) abstr k h ms s) ) abstr k h ms s)
-}
----------------------------------------------------- -----------------------------------------------------
-- evalType -- evalType

View File

@@ -37,7 +37,7 @@ import Control.Monad
import Control.Monad.State(State,evalState,get,put) import Control.Monad.State(State,evalState,get,put)
import Control.Monad.Catch(bracket_) import Control.Monad.Catch(bracket_)
import Data.Char import Data.Char
import Data.Function (on) --import Data.Function (on)
import Data.List (sortBy,intersperse,mapAccumL,nub,isSuffixOf,nubBy) import Data.List (sortBy,intersperse,mapAccumL,nub,isSuffixOf,nubBy)
import qualified Data.Map as Map import qualified Data.Map as Map
import Data.Maybe import Data.Maybe
@@ -678,7 +678,7 @@ completionInfo pgf token pstate =
Just typ -> Just typ ->
makeObj [ {-"fid".=funid,-} "fun".=cid, "hyps".=hyps', "cat".=cat, "seq".=seq ] makeObj [ {-"fid".=funid,-} "fun".=cid, "hyps".=hyps', "cat".=cat, "seq".=seq ]
where where
(hyps,cat,es) = PGF.unType typ (hyps,cat,_es) = PGF.unType typ
hyps' = [ PGF.showType [] typ | (_,_,typ) <- hyps ] hyps' = [ PGF.showType [] typ | (_,_,typ) <- hyps ]
Nothing -> makeObj [ "error".=("Function "++show cid++" not found") ] -- shouldn't happen Nothing -> makeObj [ "error".=("Function "++show cid++" not found") ] -- shouldn't happen
@@ -948,10 +948,10 @@ instance JSON PGF.BracketedString where
showJSON (PGF.Leaf s) = makeObj ["token".=s] showJSON (PGF.Leaf s) = makeObj ["token".=s]
-- * PGF utilities -- * PGF utilities
{-
cat :: PGF -> Maybe PGF.Type -> PGF.Type cat :: PGF -> Maybe PGF.Type -> PGF.Type
cat pgf mcat = fromMaybe (PGF.startCat pgf) mcat cat pgf mcat = fromMaybe (PGF.startCat pgf) mcat
-}
parse' :: PGF -> String -> Maybe PGF.Type -> Maybe PGF.Language -> [(PGF.Language,PGF.ParseOutput,PGF.BracketedString)] parse' :: PGF -> String -> Maybe PGF.Type -> Maybe PGF.Language -> [(PGF.Language,PGF.ParseOutput,PGF.BracketedString)]
parse' pgf input mcat mfrom = parse' pgf input mcat mfrom =
[(from,po,bs) | from <- froms, (po,bs) <- [PGF.parse_ pgf from cat Nothing input]] [(from,po,bs) | from <- froms, (po,bs) <- [PGF.parse_ pgf from cat Nothing input]]
@@ -969,7 +969,7 @@ complete' pgf from typ mlimit input =
then (bs, unwords (if null prefix then ws' else ws'++[prefix]), Map.empty) then (bs, unwords (if null prefix then ws' else ws'++[prefix]), Map.empty)
else (bs, prefix, PGF.getCompletions ps prefix) else (bs, prefix, PGF.getCompletions ps prefix)
where where
order = sortBy (compare `on` map toLower) --order = sortBy (compare `on` map toLower)
tokensAndPrefix :: String -> ([String],String) tokensAndPrefix :: String -> ([String],String)
tokensAndPrefix s | not (null s) && isSpace (last s) = (ws, "") tokensAndPrefix s | not (null s) && isSpace (last s) = (ws, "")