- Many modules depend on
ConCat.CircuitforAbsTy. Find another solution, perhaps via default methods with default signatures. - Define utility functions to do most of the work of various plugin transformations, including application, abstraction, pairing, etc.
- Move (some?) todo items to github repo.
- Look for a better solution to the problem of GHC eagerly inlining methods.
My current workaround is
ConCat.CategoryvsConCat.AltCat. Inconvenient for adding classes (likeChoiceCatinConCat.Choice). Could I instead recognize the dictionary selectors? - Mystery with
RBin N3vs expanded form. The former terminates, while the latter doesn't. See "fft_fc_octet" example in hardware/test/Examples.hs. - Failure with unboxed
letbindings. See notes from 2017-07-15. - Principled replacement for the
delayhack (defined inConCat.Misc). - SMT depends on z3, which takes some work to install. Maybe disable SMT by default in concat-examples.cabal, with a flag to enable it.
- I think the ghc-typelits-knownnat plugin works in GHCi. What's stopping concat-plugin from doing the same?
- Automated testing.
- Associated types for product, coproduct, exponential,
Bool,Int, etc. The type ofcccwill have to change, moving closer to the categorical notion of functor (and cartesian functor, closed cartesian functor, etc) - Users' guide / misc notes.
- Document and begin fixing robustness issues.
- Study performance, and begin improving:
- AD seems rather slow. Perhaps due to lots of inlining and simplification.
- Clean up & simplify implementation (once automated testing is in place), particularly
ConCat.Plugin. - Translate case to
DistribCat. - Categories/back-ends:
- Verilog back-end, starting with the circuit graph category in
ConCat.Circuitfrom concat andCircat.Netlistfrom circat. We'll needFloatandDoubleliterals, not currently supported by the KU netlist libraries. - Linear maps with native target representations rather than inlining.
- GPU via CUDA or OpenCL, perhaps starting with the graph/circuit category (as with dot, Verilog, and GLSL)
- Interval analysis (
ConCat.Interval): more operations. - Polynomials
- Probabilistic computation
- Other Kleisli categories
- JavaScript generation
- Circuit graphs: rework with statically typed primitives.
- Cleaner optimization
- How to hash-cons?
- GLSL: optimizations to introduce SIMD
- Optimization, e.g., along the lines of z3cat.
- Automatic differentiation:
- Back-ends with explicit tensor representations. Experiment with associating composition.
ClosedCatinstance?
- A GUI category, along the lines of Tangible Functional Programming.
- Verilog back-end, starting with the circuit graph category in
- Improve treatment of coercions, replacing
CoerceCatwith composed uses ofRepCat. (I've not managed to do so.) CoproductCatinstance inConCat.Circuit.- Better use of GHC optimizations so that need less (ideally none) in
ConCat.Circuit. - Recursion. Would help make a compelling case for compiling-to-categories vs deep DSLs.
- Get rewrite rules to work better.
Coercions and
letbindings sometimes interfere. - Use dump-core (GitHub) to view generated Core.
- Representation/levity polymorphism, so that we can used unboxed primitives, rather than having to reverse GHC unboxing work.
- Compilation with AD is slow. Diagnose, and improve.
- Maybe I should replace pin numbers by component numbers and output index (usually 0). I could perhaps identify components by a sequence of component indices within the ancestor chain, like stack frames.
- Figure out how not to need orphan instances in
ADandIncremental. - Better way to select orphan modules in
runTcMUnsafeinBuildDictionary. - General
TerminalCatdefault viaConstCatinCategory. Revisit allTerminalCatinstances. - Maybe I don't need
ConstCat (:>)for anything but scalars, since the compiler will keep breaking down constant terms until it gets to a type for which the target category has aConstCatinstance. - Demand analysis at category.
- Comment out
PseudoFunannotations to see if anything breaks. - Use
typeRfromMiscto replace uses oftypeRep. I don't think I'm still usingtypeRep. - In
Plugin, refactor common functionality between "top" & "lam" transformations. - Name possibilities:
- Catskill (though Catskell)
- Maybe have
buildDictionaryaccumulate error messages rather than selecting among them. - Sort out the problem with solving
Coercibleconstraints as needed forCoerceCat (->). Came up with second derivatives. See 2017-01-01 notes, including note to Richard Eisenberg. - Larger tests, using shaped-types.
- Remove old code from
Plugin. - Add a test for derivatives without circuits, running the generated Haskell AD code.
-
Circuit: try making nodes forabst,repr, andcoerce. - Restore the
Coercibleconstraint inConCat.Circuit, and figure out why theCoerceCatconstraint isn't getting satisfied. - Does
ConvertBwork with constant propagation inConCat.Circuit? - Why does the
Coercibleconstraint suffice forCoerceCatinLinearRowbut not inLinearCol? - Explore eliminating
abstReprCase(and perhapsabstReprCon). Does unfolding suffice as an alternative? Not quite, since lambda-bound variables can appear as scrutinees. Maybe we could eliminate that possibility with another transformation. - After various optimizations, retry
ADFunagain for comparison. - Converting to the
Trivialcategory leads to run-time error: "Impossible case alternative". - Rewrite rule loop involving "
foo2" and "uncurry id" inAltCat. - In
LinearRowandLinearCol, retry my oldscaleLdefinition viaKeyedandAdjustable, comparing for robustness and speed. -
SPECIALIZEvector space and linear map operations for some common functors, particularlyPar1, e.g.,scaleLas used for numeric primitives. - In
Plugin, factor outreturn (mkCcc (Lam x ...))(for lam) and maybe alsoreturn (mkCcc ...)(for top). - Maybe switch from
INLINEtoINLINABLE. - Eliminate the hack of first
cccing to(->), letting simplifications happen, and thencccing to another category, say withoutClosed. I think I'd have to improve my ability to do withoutClosed, including floating or substituting moreletbindings. - I think I'll want to rename
ProductCat,CoproductCat, andClosedCatto "Cartesian", "Cocartesian", and "Closed". What about otherCategorysubclasses? - There are
caseandletexpressions in the middle of categorical compositions, where they can thwart CCC simplifications. Inlining thoseletexpressions may be exactly what's needed to enable the simplifier's other transformations to eliminate thecaseexpressions. - Simple, general treatment of
ccc (\ _ -> U)asconstFun (ccc u). Oops! Take care. If I have to$\eta$ -expandU, I'll then getapply . (constFun (ccc U) &&& id). Needs more thought. - Look into work replication. See 2016-11-30 notes.
- Better CCC optimization.
- Why aren't the syntactic
BoolCat,NumCatetc methods inlining, while theCategory, andProductCatones are? - Other CCCs:
- All CCCs (universally quantified)
- Automatic differentiation
- Fancier data types via
HasReporControl.Newtype. - More rule-based optimization.
Add more here as I encounter them.
-
Add
INLINEpragmas for the method defaults inConCat.Category. So far, I've added them for just a few(***),subC,recipC,divideC. See personal notes for 2017-08-25. -
Experiment with
-fexpose-all-unfoldingsas an alternative to explicitINLINEdeclarations. Also considerINLINABLE. -
Add a plugin flag for showing the Core resulting of the plugin's pass.
-
Split concat into a few packages/repos:
- Constrained categories ("concat")
- The compiler plugin
- Example categories and uses
Make sure that it's easy & quick to build and run examples after the other packages change, without having to check in. For instance, use a stack.yaml with local package references.
-
Matches on
Intliterals lead to an error: "lam Case of boxer: bare unboxed var". -
Fix the problem with finding numeric and show instances for
Float&Double, and then simplifyCircuitagain to use 0 instead ofEql(fromIntegerZ 0),negateinstead ofnegateZ, etc. -
Remove
ConCat.Float. -
Reboxing of
divideFloat#anddivideDouble#. The rules inConCat.Rebox(commented out) don't work, perhaps because those operations can fail. Simplest solution may be to rebox those primitives programmatically in another simpleBuiltinRule. -
Re-organize
GADandIncremental. Leave only general support inGAD, and move specific toADandIncremental. -
Try
Coercion(fromData.Type.Coercion) as an example of constrained categories. Note thatCoercion a b =~ Dict (Coercible a b). Similarly for(:~:)inData.Type.Equality. -
Track down problem with
doubleexample andderiv. Error message: "unFunBgot unexpected busConvertB (<function>)". Happens when I usenewtypeinstead ofdataforDinADand dropHasLfromOkLMinLinearRow. Fixed with arevealadded todfuninAD. -
Now that I'm unfolding more effectively (even with value args), maybe I no longer need the
revealhack. My first test inADfailed, but I may need to tweakunD'also. Update: I addedrevealindfunaftercccand beforeunD. Greatly improved simplification, and sped up compilation. -
Prettyinstances forGHC.GenericsinOrphans. -
Have
buildDictionaryyield an error message when it fails, replacing theMaybereturn type with a sum. Then havePlugindisplay that message and terminate when appropriate. -
In
ConCat.Category, moveTrivialand(:**:)to before Category, and move their class instances to just after each class definition, alongside(->). -
Circuit: perhaps add aReprB, and don't worry about cancelingAbstBandReprB. -
Another idea about casts. Maybe I can operate not on the coercions but on their domain and range types as yielded by
coercionKind. Then I wouldn't have to concoct sketchy coercions.- When domain and range agree, yield
id. - If both are function types, use
(<~)as now. - If the domain type has a
HasRepinstance, pre-composerepr, recursively "solving" for the other factor. - If the range type has a
HasRepinstance, post-composeabst, solving for other factor.
I think this algorithm is the essence of what I'm doing now.
- When domain and range agree, yield
-
Move bottom-hiding
unsafeCoercehack fromAltCatto a more general definition inMisc. Then use inAltCatforccc. -
Circuit:EqandConvertB. I'll probably have to switch to heterogeneous equality, perhaps viaTestEqualityinData.Type.Equality. I'm not usingEqfor now, so I've commented out the instance. Oh! Now thatConvertBrequiresTypeable, I can implementEqviaeqT. -
Circuit: Try to unifyAbstBandConvertB. Might require changingabstCandreprCto be likeabstC'andreprC', which would probably be fine. -
Remove HERMIT dependency! I copied over
HERMIT.GHC.Typechecker. -
In
recast, when handingAxiomInstCoandSymvariant, check forHasRepinstances. -
In
Syn, use the pretty-printing class. -
Undo the
NOINLINEhack for numeric category operations, which is there for reboxing. -
Find a way to localize the reboxing transformations (performing them only under
ccc), so that they don't cause general slow-down. Then restore late inlining toAltCatops. -
Change the
ConstCat Syninstance to pretty-print instead ofshowing, so that the layout logic works. -
Move my transformations earlier, before stage zero, and make
AltCatoperations inline at stage zero. -
Experiment with running the plugin much later. Try second to last. Use
newtype-wrappedIntas well asFloatandDouble, scheduled to inline just after the plugin, i.e., phase 0. Hm. Given thederivingspecification, can I delay inlining? -
Add functions like
sinFloattomonoInfoinPlugin. -
Better solution for numeric operations on
FloatandDouble, which don't work, perhaps due to orphan instances. My temporary workaround isFloat. -
In
Plugin, try going directly fromAxiomInstCoandSymCo AxiomInstCotoreprCandabstC. Failed. -
Handle
newtypebetter, and change somedatauses back tonewtype. -
Fix
transCatOpinPluginto fail gracefully if the target category doesn't inhabit the neededCategorysubclass. Fall back to unfolding. Then fix theConstCat (->)instance inCategory, and replaceP.constbyconstinCircuitandLambda. -
In
Plugin, maybe float/subst when an expression is only used once. I think this one change would save a lot of work and lead to smaller CCC expressions. -
Other CCCs:
- A syntactic CCC for showing.
- Use to test rule-based optimization.
- I have a start in src/ConCat/Unused/.
- Keep primitives simple, say as a string naming the primitive.
- Try to do all optimization via GHC rules.
- Would be nice to pretty-print rather than
show.
- A syntactic CCC for showing.
-
Inspect categorical code, and start optimizing.
-
Work around problem with numeric operations on
FloatandDouble. I added a moduleFloatwithFloatandDoubletypes thatnewtype-wrap the standard versions. -
AD with non-scalar domains.