Giter Site home page Giter Site logo

Comments (7)

jeffreyrosenbluth avatar jeffreyrosenbluth commented on June 12, 2024

It might be interesting to take a pause and think about how we handle styles and attributes. In diagrams we basically have 2 extensible features, primitives and attributes. Primitives are statically typed but attributes are dynamic, see https://wiki.haskell.org/Diagrams/Dev/Expression for a discussion about making primitives dynamic.

It seems we've settled on statically typed primitives. I wonder whether we should think about treating attributes like primitives and consider the pros and cons. I doubt we will actually want to do this, but I think it is a good time to consider it.

from diagrams-core.

cchalmers avatar cchalmers commented on June 12, 2024

If we want to implement fading (using the luminosity of a rendered diagram as an alpha channel) or pattern fills (tiling a diagram to use as a path's fill) we'd need to add b annotations to Attribute and Style.

I'm leaning towards dynamic primitives. Right now the only case where it's useful is for images but I could see 3D backends being more selective with features they support. I'd still be happy with issuing warnings when a backend gets something it doesn't support.

That said I think the original issue is separate and can be implemented without (hopefully) breaking user code or backends, it just helps us make less mistakes in the library code.

from diagrams-core.

jeffreyrosenbluth avatar jeffreyrosenbluth commented on June 12, 2024

@cchalmers take a look at the now bit-rotted dynamic branches of -core, -lib and -svg were I played around with dynamic primitives.

from diagrams-core.

cchalmers avatar cchalmers commented on June 12, 2024

Yeah, the more I think about it the more I'm in favour of ditching the b. Changing the code doesn't seem too hard, the bigger problem would be documenting / reporting errors / changing Diagram alias again.

from diagrams-core.

jeffreyrosenbluth avatar jeffreyrosenbluth commented on June 12, 2024

I wonder if it makes sense to try and merge master into dynamic. Or if it's easier just to start from scratch. @cchalmers before you do any more work on it, we should see if there is a consensus amongst the team. If I remember correctly, when I wrote this others were leaning towards keeping the b

from diagrams-core.

byorgey avatar byorgey commented on June 12, 2024

Static vs dynamic primitives aside, I'm definitely in favor of making attributes more type safe. I've definitely stumbled over (read: had to debug) this too. The proposed solution looks good to me. DataKinds was introduced in GHC 7.4 so we are certainly good to start depending on it.

from diagrams-core.

byorgey avatar byorgey commented on June 12, 2024

(For the record, I am still torn on static vs dynamic primitives.)

from diagrams-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.