11
.
4
.
2017

Putting in overtime with Elm

Exploring purely functional programming with Elm

Tinkering with new technologies or ideas is a fun & efficient way to become a better software engineer. At comSysto we acknowledge this by providing lab days.

My co-worker Sekib and I decided to spend our lab days with Elm, a functional compile-to-JavaScript programming language to a get a glimpse of the future frontend programming. Our goal was to facilitate overtime calculation at comSysto, thus we created harvest-overtime.

Harvest is a tool we use for hour tracking & invoice creation. It’s tedious to calculate your overtime hours but luckily for us harvest offers an API and we happen to be programmers.

Currently harvest-overtime runs in “production” on a github-page and can be accessed by anyone with a comSysto account. You can check the overtime hours for the last four years and customize your weekly working hours.

Screenshot Harvest Overtime
Screenshot Harvest Overtime

SO, WHY ELM?

Advantages

If you’ve already read about Elm you have probably heard some praising about its error messages; to sum it up, everything is true. I’ve never seen better ones. I hope that other languages, libraries and frameworks get inspired to improve their errors, too. Just have a look at these two examples:

Naming Error
‍Naming Error
Type Mismatch
‍Type Mismatch

But it does not stop there. Elm’s Type system catches a lot of bugs before your program even starts. You’ll get an easy introduction to functional programming without mentioning any complex functional abstraction (looking at you Monad), while profiting of all the good things e.g. immutability, predictability and composability.

Drawbacks

So is everything great in Elm world? Of course there are some drawbacks. Talking with anything outside of Elm is tedious. For instance, any JSON response of a server input needs to be decoded to an Elm record. That’s not really a hard task but you need write a fair amount of code to get it running. As a JavaScript developer the main feature I’m missing is npm install everything (even if you should use that with great caution), Elm is still young and there’s not yet a library for everything. However, this is a great opportunity to contribute to the community.

LIBRARY CREATION HARVEST-API

Being good OSS citizens we have separated a harvest-api library from our main harvest-overtime project and published it to elm-package. The library wraps the harvest REST API and removes the need for decoding if you want to built something on top of harvest.

Publishing Elm packages is not really complicated. You can find all instructions here. Please read it but the most important takeaways are:

  1. Have a proper README.md
  2. Create decent docs for your library as described in elm-package documentation. You can preview the docs with this nice tool
  3. Tag your library (e.g. git tag -a 1.0.0 -m "release notes" and git push --tags) and make sure that the version in elm-package.json matches the label. When this is done the only thing left is to publish the library with elm-package publish. That would be it ;-)

FUTURE WORK & REPO

If this blog post got your interest on Elm, we’re looking forward to your issues and pull requests for harvest-overtime and harvest-api. Or maybe you decide to work with us as a new employee or customer.

We’d like to thank the harvest team for their help creating harvest-api and their attributions to us on their page.

Thomas
Software Engineer - Javascript
Sekib
Lean Java Expert 

Passion, friendship, honesty, curiosity. If this appeals to you, comSysto may well be your future. Apply now to join our team!

Show me the jobs!