Effect CommunityEC
Effect Community2y ago
7 replies
jessekelly

Updating Dual Function to Data-Last Format

I wonder if it would be beneficial to update the dual function to call the implementation in a data-last way instead of the current data-first way.

I.e. this:

const sum: {
  (that: number): (self: number) => number
  (self: number, that: number): number
} = dual(2, (that: number) => (self: number): number => self + that)


instead of this:

const sum: {
  (that: number): (self: number) => number
  (self: number, that: number): number
} = dual(2, (self: number, that: number): number => self + that)


Under certain circumstances this would allow you to optimize performance for the data-last case by pre computing some values, etc.
Was this page helpful?