AlgebraicJulia / Catlab.jl

A framework for applied category theory in the Julia language
https://www.algebraicjulia.org
MIT License
607 stars 58 forks source link

Programmatic API for signatures and syntax systems #15

Open epatters opened 7 years ago

epatters commented 7 years ago

Currently the code for parsing and code generation are fused together in the @signature and @syntax macros. There should be a clean separation between the macros and the underlying functionality. This will enable a programmatic API for creating, inspecting, and manipulating signatures and syntax systems.

Related to but more general than #5

jpfairbanks commented 4 years ago

I know this issue is related to general refactoring and improvement of the metaprogramming powering the GATExpr stuff. This package which implements ML/Haskell style patternmatching as julia macros might make things easier. https://github.com/thautwarm/MLStyle.jl#generalized-algebraic-data-types

I know adding more dependencies isn't always a good thing, but this has been around for over a year and everythin @thautwarm does is usually awesome. Just putting it out there as something that could help. Then we could implement GATs out of GADTS so we can can have algebraic data while we have algebraic theories.

thautwarm commented 4 years ago

Hi, thank you for mentioning me here. I'm very interested in your works and, I checked your documentation, it seems that @signature and @instance are very close to some notions such as implicit first class modules or type classes.

I guess this repo, my type class implementation in Julia, might be helpful to your works.

Further collaboration is always welcome.

jpfairbanks commented 4 years ago

This example seems particularly relevant https://thautwarm.github.io/CanonicalTraits.jl/stable/#Use-Case:-Modeling-Algebraic-Structures-1

thautwarm commented 4 years ago

Glad to know this. I know some about universal algebras but not familiar with categories. When you want to start refactoring this, feel free to ask me to work together(since Feb 1, I will have some bandwidth).

P.S: MLStyle can be developing time only dependencies, so don't worry about the dependency issues, if you can get help from mine. However, the generated code now is actually unreadable because currently there's no way to dump Julia ASTs to restore-able and readable source code.

epatters commented 4 years ago

@jpfairbanks, thanks for noticing this connection.

@thautwarm, your package looks very nice! There is definitely overlap here, which is not surprising since Catlab's signatures/instances was inspired by a similar feature in the now defunct Cateno, which was in turn inspired by Haskell type classes. When I have the bandwidth to start addressing the issue, I'll reach out to see what we can do together.

epatters commented 4 years ago

BTW, from my perspective, universal algebra has been swallowed by category theory. You can do universal algebra categorically, using Lawvere theories, but category theory has the tools to generalize and mutate universal algebra in all sorts of directions that are not obvious within the framework of traditional universal algebra.