Typical way to structure a context function based Scala 3 CRUD app

Traditionally, when I program a CRUD app, usually the program is structured with different layers such as

  • Models
  • DAO
  • Middleware for business logic
  • Configuration
  • and so on

Recently I read some articles like [1][2]. There examples like Print, Executable are provided, which is nice. But I have a question. What is a recommended way to structure a context function based Scala 3 CRUD program if my employer asks me to accomplish such tasks?

Also, is it possible to use context function to achieve the effect of IO monad like Cats Effect, or ZIO? I read that APIs like suspension/ continuation are needed, but I can’t find the links I read about those info now. Any related news?

I appreciate any advice. Thanks

[1]. Context is King. Context functions in Scala 3 | by Adam Warski | SoftwareMill Tech Blog | SoftwareMill Tech Blog

[2]. Noel Welsh: Direct-style Effects Explained

Here is an example of a small app that use typelevel stack and also contextual abstraction: GitHub - lichess-org/lila-search: Keep elasticsearch threads out of your web facing app, kids

Don’t hesitate to ask any question.

1 Like