Giter Club home page Giter Club logo

Comments (5)

johannesjh avatar johannesjh commented on May 23, 2024 1

This is awesome, thank you, great work on numbat!! (I think we can close this issue, thank you so much!!!)

from insect.

sharkdp avatar sharkdp commented on May 23, 2024

This is an excellent idea, thank you very much. And I have good news. I am currently working on a complete rewrite on Insect. One of the key new features is that users are able to define units on their own (see unit keyword below, and ignore the additional dimension definition for now... this might not be mandatory in the future). I translated your pseudo Insect code to actual Insect-new code:

image

And this program correctly prints what you expected:

500.000000 workday
300.000000 workday
5.000000 FTE

(yeah, I need to work on the output formatting)

The bad news is that this new version is quite far from feature parity with the current version, so this will take some time until I can release it.

In the meantime, we could certainly think about introducing this to the current version somehow, but hard-coding those units (e.g. workday = 8 workhours) seems a bit strange.

from insect.

johannesjh avatar johannesjh commented on May 23, 2024

Hi! Thank you, these are great news regarding the rewrite!! (note about the custom dimensions, sympy seems to have a similar separation between units and their underlying dimensions... and yes, I also think that workhours are best represented in a different dimension than regular time).

In the meantime, a minimal change would be to only introduce a single, hardcoded dummy unit, either workhour or workday. This would enable all of the above calculations without hardcoding any country- or project-dependant stuff. This change would add a single line of code, similar to Q.workhour ==> ["workhour", "workhours", "manhour", "manhours"], right? Would you accept this as PR - or be so kind to implement it yourself, since I have never programmed in purescript yet?

thank you and best regards, Johannes

from insect.

sharkdp avatar sharkdp commented on May 23, 2024

In the meantime, a minimal change would be to only introduce a single, hardcoded dummy unit, either workhour or workday. This would enable all of the above calculations without hardcoding any country- or project-dependant stuff.

I don't think that works. We do have "dummy" units like this, see: #136 (comment). We could abuse e.g. piece to mean "workhour". But then this happens:

image

That is correct, but we can not convert to workdays, because that is not a proper unit:

  result ➞ workday

   = 4000 piece

As a workaround, you can do

  result / workday

   = 500

which yields the desired result. But it's a bit unsatisfactory.

This change would add a single line of code, similar to Q.workhour ==> ["workhour", "workhours", "manhour", "manhours"], right?

There is a bit more work involved in a dependency: https://github.com/sharkdp/purescript-quantities — but following what we do for e.g. "piece" or "person" should work.

from insect.

sharkdp avatar sharkdp commented on May 23, 2024

@johannesjh You can now play with this online: https://numbat.dev/ (I added your code as an example Numbat program here: https://github.com/sharkdp/numbat/blob/master/examples/workhours.nbt)

from insect.

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.