Proposal to add Implicit Function Types to the Language

Here’s a proposal to add implicit function types to Scala 3. An implicit function type

implicit A => B

is the logical first-class version of an implicit method

def m(implicit x: A): B

Here’s a link to the doc page.

Motivation

I have already talked at length about the promises of implicit function types, for instance at POPL 2018 or at the D-language conference. In essence,

  • they are a fundamental way of scope injection
  • they promise to make many patterns of implicit parameters more concise
  • they can replace the reader monad at a ~ 10x speedup.

For details I refer you to the talks.

This proposal is open for discussion in the community and will be discussed in our next SIP meeting, where we’ll take all your feedback into account for the approval/dismissal of this feature.

17 Likes

I think Implicit Function Types is a great thing.

But it seems that it does not suite for builder pattern in general.
Related link:

2 Likes

https://www.youtube.com/watch?v=gctI7SRKp20&feature=youtu.be&t=2086

I think you missed some details :frowning:

For example we have two DSL for sql

  • JPA Dsl
  • JDBC Dsl

We use JPA when we want to have object cash for example(low level api).
We use native SQL when we want to have full postgresql functionality for example.

Both DSL have similar grammar.

So we would not have any ability to use both DSL simultaneously if it was implemented by implicit function types.(see)

This topic was automatically closed after 27 days. New replies are no longer allowed.