From 2721f7358f5c33c48ff24817ec787c3db678ad8a Mon Sep 17 00:00:00 2001 From: hallgren Date: Mon, 28 Apr 2014 13:56:20 +0000 Subject: [PATCH] Spring cleaning Nothing major... --- Makefile | 2 +- index.html | 2 +- src/compiler/GF/Data/Operations.hs | 12 +++++++----- src/server/PGFService.hs | 10 ++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index bb11bb1ad..1a819ae68 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ all: build -dist/setup-config: gf.cabal Setup.hs +dist/setup-config: gf.cabal Setup.hs WebSetup.hs cabal configure build: dist/setup-config diff --git a/index.html b/index.html index 134396285..c4291c9ac 100644 --- a/index.html +++ b/index.html @@ -26,7 +26,7 @@ document.write('

Grammatical Framework

diff --git a/src/compiler/GF/Data/Operations.hs b/src/compiler/GF/Data/Operations.hs index 501cdfd55..cd42156d4 100644 --- a/src/compiler/GF/Data/Operations.hs +++ b/src/compiler/GF/Data/Operations.hs @@ -31,7 +31,9 @@ module GF.Data.Operations (-- * misc functions lookupTree, --lookupTreeMany, lookupTreeManyAll, updateTree, buildTree, filterBinTree, - sorted2tree, mapTree, mapMTree, tree2list, + --sorted2tree, + mapTree, --mapMTree, + tree2list, -- * printing @@ -167,16 +169,16 @@ updateTree (a,b) = Map.insert a b buildTree :: (Ord a) => [(a,b)] -> BinTree a b buildTree = Map.fromList - +{- sorted2tree :: Ord a => [(a,b)] -> BinTree a b sorted2tree = Map.fromAscList - +-} mapTree :: ((a,b) -> c) -> BinTree a b -> BinTree a c mapTree f = Map.mapWithKey (\k v -> f (k,v)) - +{- mapMTree :: (Ord a,Monad m) => ((a,b) -> m c) -> BinTree a b -> m (BinTree a c) mapMTree f t = liftM Map.fromList $ sequence [liftM ((,) k) (f (k,x)) | (k,x) <- Map.toList t] - +-} filterBinTree :: Ord a => (a -> b -> Bool) -> BinTree a b -> BinTree a b filterBinTree = Map.filterWithKey diff --git a/src/server/PGFService.hs b/src/server/PGFService.hs index e51e9c625..d5f93f624 100644 --- a/src/server/PGFService.hs +++ b/src/server/PGFService.hs @@ -304,7 +304,7 @@ pgfMain command (t,pgf) = "linearize" -> o =<< doLinearize pgf # tree % to "linearizeAll" -> o =<< doLinearizes pgf # tree % to "linearizeTable" -> o =<< doLinearizeTabular pgf # tree % to - "random" -> cat >>= \c -> depth >>= \dp -> limit >>= \l -> to >>= \to -> liftIO (doRandom pgf c dp l to) >>= o + "random" -> o =<< join (doRandom pgf # cat % depth % limit % to) "generate" -> o =<< doGenerate pgf # cat % depth % limit % to "translate" -> o =<< doTranslate pgf # input % cat % to % limit %trie "translategroup" -> o =<< doTranslateGroup pgf # input % cat % to % limit @@ -312,10 +312,7 @@ pgfMain command (t,pgf) = "grammar" -> o =<< doGrammar pgf # requestAcceptLanguage "abstrtree" -> outputGraphviz =<< abstrTree pgf # graphvizOptions % tree "alignment" -> outputGraphviz =<< alignment pgf # tree % to - "parsetree" -> do t <- tree - Just l <- from - opts <- graphvizOptions - outputGraphviz (parseTree pgf l opts t) + "parsetree" -> outputGraphviz =<< parseTree pgf # from1 % graphvizOptions % tree "abstrjson" -> o . jsonExpr =<< tree "browse" -> join $ doBrowse pgf # optId % cssClass % href % format "html" % getIncludePrintNames "external" -> do cmd <- getInput "external" @@ -595,8 +592,9 @@ doLinearizeTabular pgf tree (tos,unlex) = showJSON | (ps,ts)<-texts]] | (to,texts) <- linearizeTabular pgf tos tree] -doRandom :: PGF -> Maybe PGF.Type -> Maybe Int -> Maybe Int -> To -> IO JSValue +doRandom :: PGF -> Maybe PGF.Type -> Maybe Int -> Maybe Int -> To -> CGI JSValue doRandom pgf mcat mdepth mlimit to = + liftIO $ do g <- newStdGen let trees = PGF.generateRandomDepth g pgf cat (Just depth) return $ showJSON