1. 1

    If you create a bunch of types in typescript and then try to have the typechecker catch all possible error states so that it wouldn’t compile a runtime error (but maybe a functional bug would still happen), isn’t this Elm? You model out your problem and you lean heavily on the types of that model. Then you write functional/business-y tests?

    I’m not declaring this, I’m more like asking. :) I’ve done way more typescript than Elm but not years and years of either.

    1. 3

      This is indeed the idea behind type systems like Elm’s, and Elm takes the idea a bit further than comparable languages by being very restrictive about sources of non-determinism. So if you try to utilize types to their fullest, then I’d say you’re doing things in the spirit of Elm but you won’t be able to get the same guarantees from a language that wasn’t designed from the ground up to be able to make strong guarantees the way Elm was. And in any case, having a strong type checker doesn’t obviate the need for unit tests (or unit-level tests, whether they are classical example-based tests or not), although you’ll probably not need to write as many, since their are fewer degrees of freedom in the interactions between the units/modules in your system.

      1. 3

        isn’t this Elm?

        Hi! I’m the blog post author and yes this concept is heavily encouraged in Elm! I have a few other blog posts that go into more detail if you’re interested to learn more. With* Functions, Phantom Types, The Never Type, and Opaque Types are all related to being deliberate about modeling data and defining function / module interfaces.

        Also, Richard Feldman gave a good talk a few years ago you may find interesting - Making Impossible States Impossible

        I hope that helps!

      1. 4

        I’m beginning to think I should have named this series “Restricting function arguments in Elm”

        I do not know to what extent the author is joking, but that would have been, and would still be, a spectacularly good name. Capturing an abstractish concept in a simple sentence that explains what someone would use it for? Good stuff that we could always do with more of.

        1. 4

          Author here. Yep, agreed. I started out the series thinking I’d learn about less trivial use cases of certain types only to find out that they all converged on the same idea of restricting function arguments.