News for hackers. Stuff that matters.
Re:Defunctionalisation: An underappreciated tool for writing... by mrkeen on Monday March 09, 2020 @04:58PM (#22529726)
> I can also remember when all of this was alien to me.

The only way to make it the norm is to make it the norm.

Maybe someone sees this...

  type Expr =
    | Const of int
    | CustomOneArg of (int -> int) * Expr
    | CustomTwoArgs of (int -> int -> int) * Expr * Expr
...instead of this...

  interface Expr {
  }

  class Const extends Expr {
      public Integer val;
      public (Integer val) {
          this.val = val;
      }
  }

  class CustomOneArg extends Expr {
      public Function<Integer, Integer> fun;
      public int val;
      public (Function<Integer, Integer> fun, Integer val) {
          this.fun = fun;
          this.val = val;
      }
  }

  class CustomTwoArgs extends Expr {
      public BiFunction<Integer, Integer, Integer> fun;
      public Integer valA;
      public Integer valB;
      public (BiFunction<Integer, Integer, Integer> fun, Integer valA, Integer valB) {
          this.fun = fun;
          this.valA = valA;
          this.valA = valB;
      }
  }
... and thinks "I should look into this more".

That said, I don't want to put words into the author's mouth, but this particular article looks more "by FPers for FPers" than FP advocacy.

Re:Defunctionalisation: An underappreciated tool for writing... by akra on Monday March 09, 2020 @07:03PM (#22530881)
For me its not the code/language that is un-intelligable (all code would require me to stop and try to brain interpret it); but the fact that the article at least to me refers to too many things at once. Talking about dependency handling, using data structures with dispatch vs direct function calls, data types for errors vs exceptions, expressions, etc makes the article dense to read and hard to skim.

Many programmers have used these techniques even outside FP and would be able to understand it one concept at a time - they aren't advanced concepts to me. It's more that it isn't "easy reading"; but it seems its for an internal audience with assumed background knowledge.

Re:Defunctionalisation: An underappreciated tool for writing... by dfgdghdf on Monday March 09, 2020 @05:44PM (#22530159)
The author said in a comment here that it was written for an FP audience.

The example you gave is similar to a discriminated union in ML but it is not as robust because the language will not check that every match expression (probably an if-instanceof-ladder in Java) handles every case.

Re:Defunctionalisation: An underappreciated tool for writing... by frequentnapper on Monday March 09, 2020 @05:04PM (#22529786)
that interface is actually an abstract or virtual class that can be extended.