Proposed Syntax Change: import given

After some experience with the new import given feature I propose a syntax change for wildcard imports.
Instead of

import p.{given _}


import p.given

The same applies for wildcard given imports in braces: given _ is contracted to just given. Given-by-type imports remain unaffected: It’s still

import p.{given T}

for those.

The rationale is that we should not make it needlessly hard to write wildcard given imports. The additional underscore after a given is not needed for disambiguation and clutters the code.

The change has been implemented in


For completeness,

import p.{given ?}

which is accepted but doesn’t seem to mean anything.

Edit: asked and answered: except for the part where the syntax isn’t rejected.

The syntax will be rejected once #9949 is merged.


Could you please remind me why import given ... syntax was rejected previously?

The reason i’m asking is imports ergonomics. I find current syntax is quite hard to manage if file has multiple imports with long packages (which is quite common for enterprise applications) and if formatters use alphabetical sorting it became messy with given in different places.

If we had keyword after import it would be easy to order and group given imports together, like:

import com.something._
import io.circe._

import given cats.implicits._
import given io.circe.syntax._

The new syntax works better with type bounds.

1 Like