- Many modules depend on
ConCat.Circuit
forAbsTy
. 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.Category
vsConCat.AltCat
. Inconvenient for adding classes (likeChoiceCat
inConCat.Choice
). Could I instead recognize the dictionary selectors? - Mystery with
RBin N3
vs expanded form. The former terminates, while the latter doesn't. See "fft_fc_octet
" example in hardware/test/Examples.hs. - Failure with unboxed
let
bindings. See notes from 2017-07-15. - Principled replacement for the
delay
hack (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 ofccc
will 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.Circuit
from concat andCircat.Netlist
from circat. We'll needFloat
andDouble
literals, 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.
ClosedCat
instance?
- 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
CoerceCat
with composed uses ofRepCat
. (I've not managed to do so.) CoproductCat
instance 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
let
bindings 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
AD
andIncremental
. - Better way to select orphan modules in
runTcMUnsafe
inBuildDictionary
. - General
TerminalCat
default viaConstCat
inCategory
. Revisit allTerminalCat
instances. - 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 aConstCat
instance. - Demand analysis at category.
- Comment out
PseudoFun
annotations to see if anything breaks. - Use
typeR
fromMisc
to 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
buildDictionary
accumulate error messages rather than selecting among them. - Sort out the problem with solving
Coercible
constraints 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
Coercible
constraint inConCat.Circuit
, and figure out why theCoerceCat
constraint isn't getting satisfied. - Does
ConvertB
work with constant propagation inConCat.Circuit
? - Why does the
Coercible
constraint suffice forCoerceCat
inLinearRow
but 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
ADFun
again for comparison. - Converting to the
Trivial
category leads to run-time error: "Impossible case alternative". - Rewrite rule loop involving "
foo2
" and "uncurry id
" inAltCat
. - In
LinearRow
andLinearCol
, retry my oldscaleL
definition viaKeyed
andAdjustable
, comparing for robustness and speed. -
SPECIALIZE
vector space and linear map operations for some common functors, particularlyPar1
, e.g.,scaleL
as used for numeric primitives. - In
Plugin
, factor outreturn (mkCcc (Lam x ...))
(for lam) and maybe alsoreturn (mkCcc ...)
(for top). - Maybe switch from
INLINE
toINLINABLE
. - Eliminate the hack of first
ccc
ing to(->)
, letting simplifications happen, and thenccc
ing to another category, say withoutClosed
. I think I'd have to improve my ability to do withoutClosed
, including floating or substituting morelet
bindings. - I think I'll want to rename
ProductCat
,CoproductCat
, andClosedCat
to "Cartesian
", "Cocartesian
", and "Closed
". What about otherCategory
subclasses? - There are
case
andlet
expressions in the middle of categorical compositions, where they can thwart CCC simplifications. Inlining thoselet
expressions may be exactly what's needed to enable the simplifier's other transformations to eliminate thecase
expressions. - 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
,NumCat
etc methods inlining, while theCategory
, andProductCat
ones are? - Other CCCs:
- All CCCs (universally quantified)
- Automatic differentiation
- Fancier data types via
HasRep
orControl.Newtype
. - More rule-based optimization.
Add more here as I encounter them.
-
Add
INLINE
pragmas 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-unfoldings
as an alternative to explicitINLINE
declarations. 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
Int
literals 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 simplifyCircuit
again to use 0 instead ofEql(fromIntegerZ 0)
,negate
instead 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
GAD
andIncremental
. Leave only general support inGAD
, and move specific toAD
andIncremental
. -
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
double
example andderiv
. Error message: "unFunB
got unexpected busConvertB (<function>)
". Happens when I usenewtype
instead ofdata
forD
inAD
and dropHasL
fromOkLM
inLinearRow
. Fixed with areveal
added todfun
inAD
. -
Now that I'm unfolding more effectively (even with value args), maybe I no longer need the
reveal
hack. My first test inAD
failed, but I may need to tweakunD'
also. Update: I addedreveal
indfun
afterccc
and beforeunD
. Greatly improved simplification, and sped up compilation. -
Pretty
instances forGHC.Generics
inOrphans
. -
Have
buildDictionary
yield an error message when it fails, replacing theMaybe
return type with a sum. Then havePlugin
display that message and terminate when appropriate. -
In
ConCat.Category
, moveTrivial
and(:**:)
to before Category, and move their class instances to just after each class definition, alongside(->)
. -
Circuit
: perhaps add aReprB
, and don't worry about cancelingAbstB
andReprB
. -
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
HasRep
instance, pre-composerepr
, recursively "solving" for the other factor. - If the range type has a
HasRep
instance, 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
unsafeCoerce
hack fromAltCat
to a more general definition inMisc
. Then use inAltCat
forccc
. -
Circuit
:Eq
andConvertB
. I'll probably have to switch to heterogeneous equality, perhaps viaTestEquality
inData.Type.Equality
. I'm not usingEq
for now, so I've commented out the instance. Oh! Now thatConvertB
requiresTypeable
, I can implementEq
viaeqT
. -
Circuit
: Try to unifyAbstB
andConvertB
. Might require changingabstC
andreprC
to be likeabstC'
andreprC'
, which would probably be fine. -
Remove HERMIT dependency! I copied over
HERMIT.GHC.Typechecker
. -
In
recast
, when handingAxiomInstCo
andSym
variant, check forHasRep
instances. -
In
Syn
, use the pretty-printing class. -
Undo the
NOINLINE
hack 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 toAltCat
ops. -
Change the
ConstCat Syn
instance to pretty-print instead ofshow
ing, so that the layout logic works. -
Move my transformations earlier, before stage zero, and make
AltCat
operations inline at stage zero. -
Experiment with running the plugin much later. Try second to last. Use
newtype
-wrappedInt
as well asFloat
andDouble
, scheduled to inline just after the plugin, i.e., phase 0. Hm. Given thederiving
specification, can I delay inlining? -
Add functions like
sinFloat
tomonoInfo
inPlugin
. -
Better solution for numeric operations on
Float
andDouble
, which don't work, perhaps due to orphan instances. My temporary workaround isFloat
. -
In
Plugin
, try going directly fromAxiomInstCo
andSymCo AxiomInstCo
toreprC
andabstC
. Failed. -
Handle
newtype
better, and change somedata
uses back tonewtype
. -
Fix
transCatOp
inPlugin
to fail gracefully if the target category doesn't inhabit the neededCategory
subclass. Fall back to unfolding. Then fix theConstCat (->)
instance inCategory
, and replaceP.const
byconst
inCircuit
andLambda
. -
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
Float
andDouble
. I added a moduleFloat
withFloat
andDouble
types thatnewtype
-wrap the standard versions. -
AD with non-scalar domains.