Ph

Phases, Scala macros for multiphase classes

Hacker News

Phases, Scala macros for multiphase classes

In adopting a functional style, I've found that I'm most tempted to break discipline when representing a single conceptual object that transitions between phases (usually before and after initialization). An arbitrary state diagram can be represented with a collection of immutable objects, but usually with a lot of boilerplate code, especially if most fields stay the same and have to be copied from object to object. I've often wondered why programming languages don't have a facility for generating, e.g. "five classes that differ in these five ways, with the following transitions between them." Beamer, a LaTeX package for making presentations, has such a thing for making a sequence of slides that differ in only one new bullet point. This is a hard question to ask a search engine because if such a thing existed, I wouldn't know what it's called. So I made it: https://github.com/jpivarski/phases is a Scala implementation of the idea using compile-time macros. I'm in the process of making it more easily deployable, but it can be tested by checking it out and changing/adding to its unit tests. This is also my first HN post. Let me know what you think!

Share card

Actual performance

1points
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Indie HackersFits the IH revenue-focused audience · Strong signals: latex · Missing: supports, reddit linkedin, podcasting
84%84% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Product HuntOn track for Day 1 leaderboard · Strong signals: mac, new, single · Missing: agents, macos, agent
76%76% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
Hacker NewsMay not resonate with HN audience · Strong signals: exist, ide, io · Missing: https docs, excited, just released
45%45% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
AppSumoMay struggle as an AppSumo deal · Missing: plus, platform, intuitive
42%42% predicted probability of success on AppSumo, based on ML models trained on real launch data.
TrustMRRLess likely to generate early MRR · Strong signals: way · Missing: mobile apps, ios, personal
33%33% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
13%13% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Missing: web3, chat, crypto
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Correct prediction on native model

Similar products

Sy
Synesthesia – Optimizing brainfuck compiler implemented as Nim macros69%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Synesthesia – Optimizing brainfuck compiler implemented as Nim macros

Hacker News33
Ya
YakshaLisp – Lisp dialect and macros for Yaksha lang60%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

YakshaLisp – Lisp dialect and macros for Yaksha lang

Hacker News2
Ya
YakshaLisp – Macros for Yaksha and Lisp Dialect53%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

YakshaLisp – Macros for Yaksha and Lisp Dialect

Hacker News5
Zi
Zig's defer/errdefer for c99 and gnu11 C via macros74%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Zig's defer/errdefer for c99 and gnu11 C via macros

Hacker News2
8c
8cc.cr – compile-time C compiler implemented as Crystal macros71%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

8cc.cr – compile-time C compiler implemented as Crystal macros

Hacker News9
Sa
Same-tbh – vim-like macros for bash60%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Same-tbh – vim-like macros for bash

Hacker News5
A
A set of dbg() macros for C51%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

A set of dbg() macros for C

Hacker News3
Un
Unbug – Rust macros for programmatically invoking breakpoints56%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Unbug – Rust macros for programmatically invoking breakpoints

Hacker News96
Cl
Clojure Macros – Lessons from unspoken symbols48%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Clojure Macros – Lessons from unspoken symbols

Hacker News3
Ke
Keysmith – Create macros for your Mac (and the web)66%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Keysmith – Create macros for your Mac (and the web)

Hacker News12