# -*- 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
cabal configure --user --enable-tests
cabal build
-tests:
+test tests: build
dist/build/dyna-selftests/dyna-selftests
# cabal test
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
----- 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?
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
-- 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
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"
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
(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?
(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 {{{
-> 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,
infixr 5 :+
--- | A heterogenous list
+-- | A heterogeneous list
data HList a where
HN :: HList '[]
(:+) :: a -> HList b -> HList (a ': b)
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 '[]
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)