-
Notifications
You must be signed in to change notification settings - Fork 43
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
Generalise vertical- and horizontal concatenation beyond the diagrams use case #94
base: master
Are you sure you want to change the base?
Conversation
These classes offer an interface for what has already been implemented with the `===` and `|||` operators, in a manner that's independent of diagrams.
Hi there, apologies for taking so long to respond. I am fine with this in principle, but I think I'd want to see a few more things before depending on it:
|
Thanks for the reply. I already thought myself about whether Prelude Data.Semigroup.Numbered> mempty ||| ["bla","blip","blumm"]
["bla","blip","blumm"]
Prelude Data.Semigroup.Numbered> ["bla","blip","blumm"] === mempty
["bla ","blip ","blumm"] I'm just not sure if this law is really that much use, and if it doesn't preclude some other reasonable instances. So, that, together with the fuzzy “modulo padding” caveat, stopped me from formulating the law explicitly so far. About documentation/examples you're right of course; I should add some. |
OK, fair enough (re: laws). Just to make sure I understand, diagrams users should in general be unaffected by this change; if one wanted to make use of it (e.g. to use |
Yes, that was my idea: users would not be affected in any way save for slightly longer build times. I won't add any dependencies to (I certainly also wouldn't mind if |
Another question: do you know which version of GHC is needed to support the type-level natural number literals? |
It needs at least GHC-7.6, but actually I've only tested it with |
So after a couple of legacy patches (mostly related to the AMP and FTP), the library now compiles on GHC ∊ {7.6, 7.8, 7.10, 8.0, 8.2}. The type-numbers aren't a problem. (They might become a problem if I did actual arithmetic with the types, but at least at the moment those numbers are basically just static identifiers.) https://travis-ci.org/leftaroundabout/numbered-semigroups/builds/308951619 |
OK, let me know when you've uploaded it to Hackage. At the moment diagrams-core builds all the way back to GHC 7.4 but I'm perfectly fine with dropping 7.4 support (in fact I'm quite sure some of the downstream diagrams packages don't support GHC 7.4 anyway). |
Diagrams has a nice
Juxtaposable
class that allows composing in arbitrary direction, and that is by nature pretty specific to diagrams. But much of the work in typical applications is actually done in only two discrete directions, horizontal and vertical, and that's something which is also done in many other applications. Apart from diagrams, it's obviously relevant for document layout, but also for matrices (though, that should arguably better be expressed in a more strongly-typed manner...).But AFAIK each of these applications, Diagrams included, has only defined operators like
===
and|||
on an ad-hoc basis.While designing a CSS-grid based presentation eDSL, I decided to not invent that wheel yet again, and instead gave the concatenation operators a general-purpose class, namely, a numbered sequence of semigroup classes.
I've put that in a small library just for the single class. Now I wonder if we could actually make
QDiagram
an instance of that class, and thus use the same operators both for diagrams and for other multidirectional-concatenatable stuff? This would be particularly useful for said eDSL since I'd like to compose both diagrams and other content in a single file, without awkward qualified names.I'd appreciate any opinion!