-
Notifications
You must be signed in to change notification settings - Fork 39
Add linear arrows #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add linear arrows #344
Conversation
Hi @oliverbunting, I'm so sorry, I don't know how I missed this PR 😕 . Can you comment a little on how you came up with this particular choice of design? Was it guided by applications? By theory? Something else |
|
Thanks! I've had time, today, to think about this some. Here are my current thoughts: Let me start by an aside. I recently wrote a paper regarding using linear functions to draw circuits, and how So, I've thought about the theoretical side of things (always good to have both a theoretical and a practical perspective). One helpful definition of an
Specifically, the The simplest way to make a linear arrow out of this is to say: let's take a profunctor from and to the (still notional) category Lin of types and linear functions. It gives us the following types. arr :: (a %1 -> b) -> p a b
(>>>) :: p a b -> p b c -> p a c -- uses base's `Category` class
first :: p a b -> p (a, c) (b, c) I've got to admit: this is a bit boring. However, it may very well be sufficient. For instance, linear With this abstraction we cannot define arrows The version you propose would correspond to making linear arrows strong monads in the bicategory of Lin-enriched profunctors. I think. I haven't fully worked this out, but I think it works. (the key point being that in a V-enrichment, you want to replace the definition of profunctor from Cᵒᵖ×D⟶Set to Cᵒᵖ×D⟶V) Since But I would be much more comfortable if we could provide evidence that the enriched definition is more suitable than the rather plain definition from above. |
@aspiwack thanks for a detailed reply. I'll confess most of that went by me - both undergrad and research is electronic engineering, and whilst I've used Haskell professionally for the best part of a decade, I've no theoretical background. To respond to your aside, and possibly explain my motivations better: Let me crudely outline my thoughts on circuit representations. It starts with the observation that in most systems the connections between circuits are bidirectional - circuits communicate using busses - in CMOS with dedicated routing master to slave in each direction (not shared routing resources). Therefore, if You can do most of this with linear My thoughts are publicly visible, although incomplete and possibly flawed, here if you're interested. I intend to finish that work, it still interests me, but free time is at a premium, so it's happening very slowly. I'd be happy to discuss, but there's got to be a better forum than this PR. Whilst doing all this a number of years ago, we basically used a source plugin hack to workaround the lack of linear types. An ex-colleague of mine, and one of those (along with christiaanb, martijnbastiaan, JonFowler) who've spent countless hours discussing circuit representations with me, has published that here. I believe its still used in production. |
Hello again, Sorry I'm taking so much time to answer. It's been busy times, I'm afraid.
It's alright, I suppose this was mostly for my personal consumption 🙂 .
Ok, so, do I understand right that, in this scenario, a
It is a bit over my head, I'm afraid.
I'm available for a call if you wish. You can send me an email. First name dot last name @tweag.io . |
Propose definitions for
Control.Category.Linear
andControl.Arrow.Linear
Happy to discuss / modify.