From: Nathaniel Wesley Filardo Date: Wed, 5 Jun 2013 00:30:27 +0000 (-0400) Subject: Small cleanups & update TODO X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=9c3484c1859380a068027e740afd916e0332828b;p=dyna2 Small cleanups & update TODO --- diff --git a/Makefile b/Makefile index 6945d0c..594cd87 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ # -*- indent-tabs-mode:t; -*- -all: build +all: deps build upstream: git submodule init - git submodule update external/ekmett-parsers external/ekmett-trifecta - cabal install --user --enable-tests --only-dependencies \ - external/ekmett-parsers external/ekmett-trifecta . - cabal install --user external/ekmett-parsers external/ekmett-trifecta + # git submodule update external/ekmett-parsers external/ekmett-trifecta + # cabal install --user --enable-tests --only-dependencies \ + # external/ekmett-parsers external/ekmett-trifecta . + # cabal install --user external/ekmett-parsers external/ekmett-trifecta deps: alex --version || cabal install alex @@ -18,7 +18,7 @@ build: cabal configure --user --enable-tests cabal build -tests: +test tests: build dist/build/dyna-selftests/dyna-selftests # cabal test diff --git a/docs/TODO.LSA b/docs/TODO.LSA index 7d41972..40438c1 100644 --- a/docs/TODO.LSA +++ b/docs/TODO.LSA @@ -11,9 +11,10 @@ Parse QMode pragmas List notation ------ Frontend +Strict end-of-rule punctuation, warn if blank line at plausible end-of-rule +position? (polish for LSA) -:= syntactic sugar +----- Frontend ----- Analysis @@ -31,35 +32,36 @@ Unification alias tracking (after LSA?) ----- Backend -Check that we have = aggregation working correctly. +",/2" runtime error if first argument is not true or false + Probably OK for this one to crash the program! -Special error value (for = agg violation, div by 0, ...) - Some flavor of "root cause" pointer / string / ... ? +Check that we have = aggregation working correctly. Could we maybe get a better chart representation? And better queries into the chart? We should be able to extract adorned queries from the planner's output without too much effort... +Prioritization heuristic + Maybe something better for initializers or update API? (Low priority) DOpAMine improvements for non-ground structure (probably no time!) ----- Documentation +Forward port shortest path tutorial + Mention ^C in documentation for diverging programs. Be sure to mention, repeatedly, that this is experimental software and is likely to break both early and often. Explain the difference between panic messages and errors. ------ Whole pipeline +----- REPL -Need some better mechanism for executing queries after the agenda empties. - Take query, feed back to compiler / planner / ... - In general, we'd need to indicate which set of things we are - at present maintaining and possibly feed the whole program back - through the pipeline... if we stick with everything being - materialized, we can just feed the query through. +Make use of resumable parsing functionality + +----- Whole pipeline Can we extract backpointers from the chart or generate code to do so? @@ -69,3 +71,21 @@ Can we run anything on e.g. WSJ with L0 grammar? How about... (other things students might want to do) train a log-linear model (e.g. by using := for weights) find the K most-frequent bigrams (even from the repl?) + +----- Things that still have bits and bobs pending + +Queries (initializers), new rule insertions (both plans and initializers) + +Need some better mechanism for executing queries after the agenda empties. + Take query, feed back to compiler / planner / ... + In general, we'd need to indicate which set of things we are + at present maintaining and possibly feed the whole program back + through the pipeline... if we stick with everything being + materialized, we can just feed the query through. + +DOpAMine improvements for logging of hyper-edges + Right now we manage this through timv's cleverness in the backend, + rather than anything formal. + +Graphical view of the hypergraph + Tim has something pretty neat working diff --git a/src/Dyna/Analysis/ANF.hs b/src/Dyna/Analysis/ANF.hs index 3095ca0..b29ec2c 100644 --- a/src/Dyna/Analysis/ANF.hs +++ b/src/Dyna/Analysis/ANF.hs @@ -301,6 +301,12 @@ normTerm_ _ ss (P.TFunctor f [t T.:~ st]) | f == dynaQuoteOper = do -- Evaluation is a little different: in addition to forcing the context to -- evaluate, it must also evaluate if the context from on high is one of -- evaluation! +-- +-- XXX This is not right. Consider ":-dispos &pair(*,*)." If I want to +-- evaluate a pair/2 in evaluation context, then I need to write &(*pair(1,2)), +-- so that the & suppresses the context's influence and * overrides the +-- pair's disposition.... actually that's true of variables, too. f(*X) +-- does not mean what it should in the new syntax. normTerm_ c ss (P.TFunctor f [t T.:~ st]) | f == dynaEvalOper = normTerm_ (ECExplicit,ADEval) (st:ss) t >>= \nt -> case c of diff --git a/src/Dyna/Analysis/Mode/Selftest/Contexts.hs b/src/Dyna/Analysis/Mode/Selftest/Contexts.hs index 5eadd1a..55e4361 100644 --- a/src/Dyna/Analysis/Mode/Selftest/Contexts.hs +++ b/src/Dyna/Analysis/Mode/Selftest/Contexts.hs @@ -83,10 +83,10 @@ alias_unifyVF n1 n2 = fmap fst $ runIdentity $ flip CA.runSIMCT (CA.allFreeSIMCtx [vA,vB]) $ do - flip runReaderT (UnifParams True False) $ do - FA.unifyUnaliasedNV n1 vA + _ <- flip runReaderT (UnifParams True False) $ do + _ <- FA.unifyUnaliasedNV n1 vA FA.unifyUnaliasedNV n2 vB - FA.unifyVF True (const $ return True) vA G [vB] + _ <- FA.unifyVF True (const $ return True) vA G [vB] FA.expandV vA where vA = "A" diff --git a/src/Dyna/Analysis/RuleMode.hs b/src/Dyna/Analysis/RuleMode.hs index adc05ac..f944208 100644 --- a/src/Dyna/Analysis/RuleMode.hs +++ b/src/Dyna/Analysis/RuleMode.hs @@ -150,10 +150,9 @@ fgn v cf cg cn = do possible :: (Monad m) => BackendPossible fbs - -> Rule -> Crux DVar TBase -> SIMCT m DFunct (Actions fbs) -possible fp r cr = +possible fp cr = case cr of -- XXX This is going to be such a pile. We really, really should have -- unification crank out a series of DOpAMine opcodes for us, but for @@ -210,20 +209,22 @@ possible fp r cr = (throwError UFExDomain) -- XXX Indirect evaluation is not yet supported - Left (eix, CEval _ _) -> dynacSorry $ "Indir eval" - <+> parens ("eix=" <> pretty eix) - <+> "in rule at" - prettySpanLoc (r_span r) + Left (_, CEval _ _) -> throwError UFExDomain -- Evaluation Left (_, CCall vo vis funct) -> do is <- mapM mkMV vis o <- mkMV vo case fp (funct,is,o) of - -- XXX Not a built-in, so we assume that it can be iterated in full. + -- XXX Not a built-in, so we assume that it can be + -- iterated in full. Left False -> do mapM_ bind (vo:vis) return [OPIter o is funct DetNon Nothing] + + -- Builtin called in improper mode; bail on this plan Left True -> throwError UFExDomain + + -- Builtin called in accessible mode; apply bindings and return Right (BAct a m) -> do runReaderT (mapM_ (uncurry $ flip unifyUnaliasedNV) m) (UnifParams True True) -- XXX Live? @@ -240,39 +241,6 @@ possible fp r cr = (throwError UFExDomain) bind x = runReaderT (unifyVU x) (UnifParams False False) -------------------------------------------------------------------------}}} --- ANF to Cruxes {{{ - -{- -anfVars :: ANFState -> S.Set DVar -anfVars (AS { as_evals = evals, as_unifs = unifs, as_assgn = assgns } ) = - S.unions [ M.foldWithKey (\k v s -> S.insert k (go1 v s)) S.empty evals - , M.foldWithKey (\k v s -> S.insert k (go2 v s)) S.empty assgns - , foldr (\(v1,v2) s -> S.insert v1 (S.insert v2 s)) S.empty unifs - ] - where - go s (_,vs) = S.union s (S.fromList vs) - go1 e s = either (flip S.insert s) (go s) e - go2 e s = either (const s) (go s) e - - -eval_cruxes :: ANFState -> [EvalCrux DVar] -eval_cruxes = M.foldrWithKey (\o i -> (crux o i :)) [] . as_evals - where - crux :: DVar -> EVF -> EvalCrux DVar - crux o (Left v) = CEval o v - crux o (Right (f,as)) = CCall o as f - -unif_cruxes :: ANFState -> [UnifCrux DVar NTV] -unif_cruxes (AS { as_assgn = assigns, as_unifs = unifs }) = - M.foldrWithKey (\o i -> (crux o i :)) [] assigns - ++ map (\(v1,v2) -> CAssign v1 (NTVar v2)) unifs - where - crux :: DVar -> EBF -> UnifCrux DVar NTV - crux o (Left x) = CAssign o (NTBase x) - crux o (Right (f,as)) = CStruct o as f --} - ------------------------------------------------------------------------}}} -- Costing Plans {{{ @@ -458,12 +426,12 @@ planUpdate :: BackendPossible fbs -> SIMCtx DVar -> Maybe (Cost, Actions fbs) planUpdate bp r sc anf mi ictx = fmap (second (finalizePlan r)) $ - bestPlan $ planner_ (possible bp r) sc anf (Just mi) ictx + bestPlan $ planner_ (possible bp) sc anf (Just mi) ictx planInitializer :: BackendPossible fbs -> Rule -> Maybe (Cost, Actions fbs) planInitializer bp r = fmap (second (finalizePlan r)) $ let cruxes = r_cruxes r in - bestPlan $ planner_ (possible bp r) simpleCost cruxes Nothing + bestPlan $ planner_ (possible bp) simpleCost cruxes Nothing (allFreeSIMCtx $ S.toList $ allCruxVars cruxes) -- | Given a particular crux and the remaining evaluation cruxes in a rule, diff --git a/src/Dyna/XXX/HList.hs b/src/Dyna/XXX/HList.hs index 4ca2865..923e9e5 100644 --- a/src/Dyna/XXX/HList.hs +++ b/src/Dyna/XXX/HList.hs @@ -106,7 +106,7 @@ instance (EqLen xs ys) => EqLen (x ': xs) (y ': ys) infixr 5 :+ --- | A heterogenous list +-- | A heterogeneous list data HList a where HN :: HList '[] (:+) :: a -> HList b -> HList (a ': b) @@ -144,7 +144,7 @@ hrlmap' f (a :+ as) = f a :+ (hrlmap' f as) infixr 5 :++ --- | A heterogenous list in which every element is the image of some +-- | A heterogeneous list in which every element is the image of some -- type-function @r :: * -> *@. data HRList (r :: k -> *) (a :: [k]) where HRN :: HRList r '[] @@ -171,7 +171,7 @@ hrlmapa :: (Applicative m) hrlmapa _ HRN = pure HRN hrlmapa f (a :++ as) = liftA2 (:++) (f a) (hrlmapa f as) --- | Eliminate a HRList to a homogenous list +-- | Eliminate a HRList to a homogeneous list hrlproj :: (forall a . r a -> b) -> HRList r t -> [b] hrlproj _ HRN = [] hrlproj f (a :++ as) = f a : (hrlproj f as)