mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
Merge pull request #19 from MUSTE-Project/master
Fix deprecations from containers >= 0.4.0.0
This commit is contained in:
@@ -57,7 +57,7 @@ pgfToCFG pgf lang = mkCFG (showCId (lookStartCat pgf)) extCats (startRules ++ co
|
|||||||
|
|
||||||
topdownRules cat = f cat []
|
topdownRules cat = f cat []
|
||||||
where
|
where
|
||||||
f cat rules = maybe rules (Set.fold g rules) (IntMap.lookup cat (productions cnc))
|
f cat rules = maybe rules (Set.foldr g rules) (IntMap.lookup cat (productions cnc))
|
||||||
|
|
||||||
g (PApply funid args) rules = (cncfuns cnc ! funid,args) : rules
|
g (PApply funid args) rules = (cncfuns cnc ! funid,args) : rules
|
||||||
g (PCoerce cat) rules = f cat rules
|
g (PCoerce cat) rules = f cat rules
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ browse pgf id = fmap (\def -> (def,producers,consumers)) definition
|
|||||||
Just (hyps,_,_) -> Just $ render (text "cat" <+> ppCId id <+> hsep (snd (mapAccumL (ppHypo 4) [] hyps)))
|
Just (hyps,_,_) -> Just $ render (text "cat" <+> ppCId id <+> hsep (snd (mapAccumL (ppHypo 4) [] hyps)))
|
||||||
Nothing -> Nothing
|
Nothing -> Nothing
|
||||||
|
|
||||||
(producers,consumers) = Map.foldWithKey accum ([],[]) (funs (abstract pgf))
|
(producers,consumers) = Map.foldrWithKey accum ([],[]) (funs (abstract pgf))
|
||||||
where
|
where
|
||||||
accum f (ty,_,_,_) (plist,clist) =
|
accum f (ty,_,_,_) (plist,clist) =
|
||||||
let !plist' = if id `elem` ps then f : plist else plist
|
let !plist' = if id `elem` ps then f : plist else plist
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ foldForest :: (FunId -> [PArg] -> b -> b) -> (Expr -> [String] -> b -> b) -> b -
|
|||||||
foldForest f g b fcat forest =
|
foldForest f g b fcat forest =
|
||||||
case IntMap.lookup fcat forest of
|
case IntMap.lookup fcat forest of
|
||||||
Nothing -> b
|
Nothing -> b
|
||||||
Just set -> Set.fold foldProd b set
|
Just set -> Set.foldr foldProd b set
|
||||||
where
|
where
|
||||||
foldProd (PCoerce fcat) b = foldForest f g b fcat forest
|
foldProd (PCoerce fcat) b = foldForest f g b fcat forest
|
||||||
foldProd (PApply funid args) b = f funid args b
|
foldProd (PApply funid args) b = f funid args b
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ filterProductions prods0 prods
|
|||||||
| prods0 == prods1 = prods0
|
| prods0 == prods1 = prods0
|
||||||
| otherwise = filterProductions prods1 prods
|
| otherwise = filterProductions prods1 prods
|
||||||
where
|
where
|
||||||
prods1 = IntMap.foldWithKey foldProdSet IntMap.empty prods
|
prods1 = IntMap.foldrWithKey foldProdSet IntMap.empty prods
|
||||||
hoc = IntMap.fold (\set !hoc -> Set.fold accumHOC hoc set) IntSet.empty prods
|
hoc = IntMap.foldr (\set !hoc -> Set.foldr accumHOC hoc set) IntSet.empty prods
|
||||||
|
|
||||||
foldProdSet fid set !prods
|
foldProdSet fid set !prods
|
||||||
| Set.null set1 = prods
|
| Set.null set1 = prods
|
||||||
@@ -204,7 +204,7 @@ filterProductions prods0 prods
|
|||||||
accumHOC _ hoc = hoc
|
accumHOC _ hoc = hoc
|
||||||
|
|
||||||
splitLexicalRules cnc p_prods =
|
splitLexicalRules cnc p_prods =
|
||||||
IntMap.foldWithKey split (IntMap.empty,IntMap.empty) p_prods
|
IntMap.foldrWithKey split (IntMap.empty,IntMap.empty) p_prods
|
||||||
where
|
where
|
||||||
split fid set (lex,syn) =
|
split fid set (lex,syn) =
|
||||||
let (lex0,syn0) = Set.partition isLexical set
|
let (lex0,syn0) = Set.partition isLexical set
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ recoveryStates open_types (EState abs cnc chart) =
|
|||||||
Nothing -> []
|
Nothing -> []
|
||||||
|
|
||||||
complete open_fcats items ac =
|
complete open_fcats items ac =
|
||||||
foldl (Set.fold (\(Active j' ppos funid seqid args keyc) ->
|
foldl (Set.foldr (\(Active j' ppos funid seqid args keyc) ->
|
||||||
(:) (Active j' (ppos+1) funid seqid args keyc)))
|
(:) (Active j' (ppos+1) funid seqid args keyc)))
|
||||||
items
|
items
|
||||||
[set | fcat <- open_fcats, (set,_) <- lookupACByFCat fcat ac]
|
[set | fcat <- open_fcats, (set,_) <- lookupACByFCat fcat ac]
|
||||||
@@ -363,7 +363,7 @@ process flit ftok cnc (item@(Active j ppos funid seqid args key0):items) acc cha
|
|||||||
|
|
||||||
items2 = case lookupAC key0 ((active chart:actives chart) !! (k-j)) of
|
items2 = case lookupAC key0 ((active chart:actives chart) !! (k-j)) of
|
||||||
Nothing -> items
|
Nothing -> items
|
||||||
Just (set,sc) -> Set.fold (\(Active j' ppos funid seqid args keyc) ->
|
Just (set,sc) -> Set.foldr (\(Active j' ppos funid seqid args keyc) ->
|
||||||
let SymCat d _ = unsafeAt (unsafeAt (sequences cnc) seqid) ppos
|
let SymCat d _ = unsafeAt (unsafeAt (sequences cnc) seqid) ppos
|
||||||
PArg hypos _ = args !! d
|
PArg hypos _ = args !! d
|
||||||
in (:) (Active j' (ppos+1) funid seqid (updateAt d (PArg hypos fid) args) keyc)) items set
|
in (:) (Active j' (ppos+1) funid seqid (updateAt d (PArg hypos fid) args) keyc)) items set
|
||||||
@@ -395,7 +395,7 @@ process flit ftok cnc (item@(Active j ppos funid seqid args key0):items) acc cha
|
|||||||
predict flit ftok cnc forest key0 key@(AK fid lbl) k acc items =
|
predict flit ftok cnc forest key0 key@(AK fid lbl) k acc items =
|
||||||
let (acc1,items1) = case IntMap.lookup fid forest of
|
let (acc1,items1) = case IntMap.lookup fid forest of
|
||||||
Nothing -> (acc,items)
|
Nothing -> (acc,items)
|
||||||
Just set -> Set.fold foldProd (acc,items) set
|
Just set -> Set.foldr foldProd (acc,items) set
|
||||||
|
|
||||||
(acc2,items2) = case IntMap.lookup fid (lexicon cnc) >>= IntMap.lookup lbl of
|
(acc2,items2) = case IntMap.lookup fid (lexicon cnc) >>= IntMap.lookup lbl of
|
||||||
Just tmap -> let (mb_v,toks) = TrieMap.decompose (TrieMap.map (toItems key0 k) tmap)
|
Just tmap -> let (mb_v,toks) = TrieMap.decompose (TrieMap.map (toItems key0 k) tmap)
|
||||||
|
|||||||
@@ -79,12 +79,12 @@ unionsWith f = foldl (unionWith f) empty
|
|||||||
elems :: TrieMap k v -> [v]
|
elems :: TrieMap k v -> [v]
|
||||||
elems tr = collect tr []
|
elems tr = collect tr []
|
||||||
where
|
where
|
||||||
collect (Tr mb_v m) xs = maybe id (:) mb_v (Map.fold collect xs m)
|
collect (Tr mb_v m) xs = maybe id (:) mb_v (Map.foldr collect xs m)
|
||||||
|
|
||||||
toList :: TrieMap k v -> [([k],v)]
|
toList :: TrieMap k v -> [([k],v)]
|
||||||
toList tr = collect [] tr []
|
toList tr = collect [] tr []
|
||||||
where
|
where
|
||||||
collect ks (Tr mb_v m) xs = maybe id (\v -> (:) (ks,v)) mb_v (Map.foldWithKey (\k -> collect (k:ks)) xs m)
|
collect ks (Tr mb_v m) xs = maybe id (\v -> (:) (ks,v)) mb_v (Map.foldrWithKey (\k -> collect (k:ks)) xs m)
|
||||||
|
|
||||||
fromListWith :: Ord k => (v -> v -> v) -> [([k],v)] -> TrieMap k v
|
fromListWith :: Ord k => (v -> v -> v) -> [([k],v)] -> TrieMap k v
|
||||||
fromListWith f xs = foldl' (\trie (ks,v) -> insertWith f ks v trie) empty xs
|
fromListWith f xs = foldl' (\trie (ks,v) -> insertWith f ks v trie) empty xs
|
||||||
|
|||||||
Reference in New Issue
Block a user