Elm Static Types — Tentamen Software Testing Blog

TL;DR

The static type describes the kind of data that could be associated with value. This post is part of the functional language series, and it is based on a remarkable book Programming Elm Build Safe and Maintainable Front-End Applications by Jeremy Fairbank.

The great source of errors in a program is when we associate with value data that do not match in type. Javascript allows this in the image above. We assigned to value number 3, string 3 and float 3.00. The assignment is not the issue here, but the problem arises when we start referencing in calculations when we expect value as a number, but user assigned string. It would be a nice feature that Javascript warns us about this in compile time.

Elm does this in compile-time because it uses static types.

We have in StaticTypes module add function, and we try to add integer and string. Here is compilation result error:

Remember

  • difference between dynamic and static type languages
  • compilation vs. runtime errors

Originally published at https://blog.tentamen.eu on July 7, 2020.

--

--

--

Founder of Tentamen, software testing agency.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Interpret “Build your Resume”

Build your resume

Experience with getting started to Software Development Lifecycle

Side by Side API In Python: An FX Example With Interactive Widgets

How to use one Test target files for Two App Targets in iOS?

What could you could learn from ‘Building Microservices’ by Sam Newman (2015, 250 pages)

How to implement password recovery securely in PHP

Simple Procedural Level Generation In Unity

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Karlo Smid

Karlo Smid

Founder of Tentamen, software testing agency.

More from Medium

Why do we test at all?

Test Ideas — Input Methods

Should Test Automation Be Left To Software Engineers?

17 Excuses Every Website Tester Should Get Rid Of Immediately