@@ -216,13 +216,11 @@ callCon con = reAppAny (var con.name) . toList . mapI (appArg . index' con.args)
216216-- "Non-obligatory" means that some present external generator of some type
217217-- may be ignored even if its type is really used in a generated data constructor.
218218
219- ||| Least-effort non-obligatory tactic is one which *does not use externals* during taking a decision on the order.
220- ||| It uses externals if decided order happens to be given by an external generator, but is not obliged to use any.
221- ||| It is seemingly most simple to implement, maybe the fastest and
222- ||| fits well when external generators are provided for non-dependent types.
223- export
224- [LeastEffort ] DeriveBodyRhsForCon where
225- consGenExpr sig con givs fuel = do
219+ -- Least-effort non-obligatory tactic is one which *does not use externals* during taking a decision on the order.
220+ -- It uses externals if decided order happens to be given by an external generator, but is not obliged to use any.
221+ -- It is seemingly most simple to implement, maybe the fastest and
222+ -- fits well when external generators are provided for non-dependent types.
223+ Deriving . DepTyCheck . Gen . ForOneTypeConRhs . Interface . consGenExpr sig con givs fuel = do
226224
227225 -- -----------------------------------------------------------
228226 -- Prepare intermediate data and functions using this data --
@@ -355,54 +353,3 @@ export
355353 let df = believe_me $ deriveFirst @{impl} (rewrite tyLen in Prelude . toList sig. givenParams) (rewrite conLen in Prelude . toList givs)
356354 let userImposed = filter (not . contains' givs) $ nub $ conArgIdx <$> df
357355 logValue FineDetails " deptycheck.derive.least-effort" [sig, con] " - user-imposed: \{userImposed}" userImposed
358-
359- -- ||| Best effort non-obligatory tactic tries to use as much external generators as possible
360- -- ||| but discards some there is a conflict between them.
361- -- ||| All possible non-conflicting layouts may be produced in the generated values list.
362- -- |||
363- -- ||| E.g. when we have external generators ``(a : _) -> (b : T ** C a b)`` and ``(b : T ** D b)`` and
364- -- ||| a constructor of form ``C a b -> D b -> ...``, we can use values from both pairs
365- -- ||| ``(a : _) -> (b : T ** C a b)`` with ``(b : T) -> D b`` and
366- -- ||| ``(a : _) -> (b : T) -> C a b`` with ``(b : T ** D b)``,
367- -- ||| i.e. to use both of external generators to form the generated values list
368- -- ||| but not obligatorily all the external generators at the same time.
369- -- export
370- -- [BestEffort] DeriveBodyRhsForCon where
371- -- consGenExpr sig con givs fuel = do
372- -- ?cons_body_besteff_nonoblig_rhs
373-
374- -- ------------------------
375- -- - Obligatory tactics ---
376- -- ------------------------
377-
378- -- "Obligatory" means that is some external generator is present and a constructor has
379- -- an argument of a type which is generated by this external generator, it must be used
380- -- in the constructor's generator.
381- --
382- -- Dependent types are important here, i.e. generator ``(a : _) -> (b ** C a b)``
383- -- is considered to be a generator for the type ``C``.
384- -- The problem with obligatory generators is that some external generators may be incompatible.
385- --
386- -- E.g. once we have ``(a : _) -> (b ** C a b)`` and ``(a ** b ** C a b)`` at the same time,
387- -- once ``C`` is used in the same constructor, we cannot guarantee that we will use both external generators.
388- --
389- -- The same problem is present once we have external generators for ``(a : _) -> (b : T ** C a b)`` and ``(b : T ** D b)`` at the same time,
390- -- and both ``C`` and ``D`` are used in the same constructor with the same parameter of type ``T``,
391- -- i.e. when constructor have something like ``C a b -> D b -> ...``.
392- --
393- -- Notice, that this problem does not arise in constructors of type ``C a b1 -> D b2 -> ...``
394- --
395- -- In this case, we cannot decide in general which value of type ``T`` to be used for generation is we have to use both generators.
396- -- We can either fail to generate a value for such constructor (``FailFast`` tactic),
397- -- or alternatively we can try to match all the generated values of type ``T`` from both generators
398- -- using ``DecEq`` and leave only intersection (``DecEqConflicts`` tactic).
399-
400- -- export
401- -- [FailFast] DeriveBodyRhsForCon where
402- -- consGenExpr sig con givs fuel = do
403- -- ?cons_body_obl_ff_rhs
404-
405- -- export
406- -- [DecEqConflicts] DeriveBodyRhsForCon where
407- -- consGenExpr sig con givs fuel = do
408- -- ?cons_body_obl_deceq_rhs
0 commit comments