Why create my own FPL

Share

Before I actually start implementing my own FPL, I should maybe explain why I’d be crazy enough to do so.

In the previous intro blog post, I already alluded to my reasons for creating GenFPL:

  1. As a use – and show – case for the LionWeb initiative I’m heavily involved with
  2. As a vehicle for talks/presentations at conferences
  3. To scratch my own itches
  4. Because I genuinely think this would be useful — even for other people than myself, or my clients

Scratching my own itches

These reasons carry over MyFPL as well, but I’d like to elaborate on reason #3. The itches I was thinking of are:

  1. Designing a FPL, and showing how to make it modular
  2. Implementing a language starting from the abstract syntax, and then using projectional editing
  3. Designing and implementing “evaluation with holes” — you may call that “partial evaluation” or not, depending on your tastes
  4. Having a FPL that can strike the balance between “too heavy” languages such as Haskell or Scala, and “too light” languages
  5. Showcasing a couple of features that I think are interesting and useful to have in a FPL, but that are definitely “non-standard”
Most of the time I don’t need a FPL with a type system that does Hindley-Milner type inference(*) but emits incomprehensible error messages. I also don’t need an enormous standard library, where everything’s five levels of indirection to flatMap. (Yes, these are complaints about some of the “mainstream” FPLs around.)

About 10 years ago, I worked through (most of) Functional Programming in Scala in a weekly group session at my then-employer. I was often perplexed and frustrated by the Scala language. (I believe we were using version 2 at the time, so pre-Dotty/version 3.) The flexibility of its syntax can be a thing of great power, but with great power comes…ah well, you get the drift. The use of implicits (AKA contextual parameters) drove me slightly nuts — as it did other members of the group, and often enough the IDE as well! Insanity was partly brought on by the terse, and often frankly incomprehensible, error messages emitted by Scala’s compiler, especially where they concerned type parameters.

About four years ago, I started reading Functional Programming in Kotlin, which is essentially the Kotlin version of the first one. The Scala gripe didn’t apply as Kotlin is an arguably simpler and cleaner language. Its type system is also not as powerful as Scala. This means that from some point in the book onwards, you have to rely on a couple of kludges to achieve the same code brevity and type assurances as the Scala version. It probably didn’t help that both Scala and Kotlin are, primarily, GPLs and not necessarily only FPLs.

So, in my experience, Scala is “too heavy” and Kotlin is “too light”, so wouldn’t it be fun to be able to work through these books using a language that occupies exactly the right spot in this spectrum? There’s a chance I would deem Haskell to be “too heavy” as well.

Usages

I’d also like to elaborate a bit on reason #4. First of all, MyFPL could – and should, although it’s questionably whether I’ll even manage, time-wise – be fed back into GenFPL. Second of all, I myself would like to use MyFPL as an embedded functional DSL in other projects — possibly with some restrictions and a different syntax.

Features to support

Some other features I’d like to support at some point in MyFPL:

  • Working with explicitly-unknown values — somewhat-AKA partial evaluation
  • First-class constructs for functional composition:
    • Point-less programming — AKA tacit programming, or “point-free style”
    • Currying by name (or given that we’re going to be using projectional editing rather than parsed-based technology: by reference to a function’s argument), rather than by position
  • Generically-variant return types
  • Decision tables

Please consider the items in this list as teasers, rather than promises… I’ll explain more about them as soon as language evolution makes it opportune to touch upon them.

I would be remiss not to mention other projects that are similar to this one. One in particular is EYG, made by Peter Saxton. It is certainly similar in adopting projectional editing, but differs in plenty of other ways. Nevertheless, go and check out EYG out as well — if only to learn why the acronym stands for “Eat Your Greens”.

Beyond the horizon

I’m a recovering mathematician, and I think there’s something to be gained by feeding good software design and development practices back into mathematics. I’m somewhat underwhelmed by existing symbolic algebra software, and how “ad hoc” they feel. I guess I also wish for an FP-style GPL with which I could do some symbolic algebra.

💡
In this blog post, I’ve explained why I want to implement MyFPL. In the next blog post, I’ll talk about the four key aspects of MyFPL.

Footnote

*) Hindley-Milner is my litmus test for whether a software language engineer is “academic” or not: if a SLE asks whether a language does Hindley-Milner – and especially why it doesn’t – they’re of the academic type.