Skip to content

Fix method signature rendering fidelity in TypePrinter#102

Open
matejcerny wants to merge 1 commit into
VirtusLab:mainfrom
matejcerny:rendering
Open

Fix method signature rendering fidelity in TypePrinter#102
matejcerny wants to merge 1 commit into
VirtusLab:mainfrom
matejcerny:rendering

Conversation

@matejcerny

Copy link
Copy Markdown

Fixes #101.

  • Curried parameter lists no longer joined with :
    • Consecutive parameter lists now render adjacently ((fa: F[A])(f: ...)) instead of (fa: F[A]): (f: ...)
    • The : separator is now emitted only before a genuine (non-methodic) result type.
  • Unbounded type parameters no longer gain explicit bounds
    • [A, B] renders as [A, B] again rather than [A >: Nothing <: Any, B >: Nothing <: Any]
    • Bounds are now elided by comparing the printed bound against Nothing/Any rather than its raw toString.

Additional rendering fixes

  • Function-type sugar
    • Function1[A, B] now renders as A => B and ContextFunctionN as ?=> ..., with parentheses added where required - around a function-typed left operand ((A => B) => C) and around arrow sugar in extends position.
  • implicit parameter lists
    • Legacy implicit param lists now render with the implicit keyword (previously only using was handled).

Tests

Added TypePrinter unit tests plus Scala 2 and Scala 3 fixtures (CellarCurried, CellarSugar) covering:

  • curried lists
  • function/context-function sugar
  • using/implicit parameters

Updated the README example output to match.

@matejcerny

Copy link
Copy Markdown
Author

cc @rochala 🙏

@rochala

rochala commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for contribution. I'll take a look at it during the weekend. Sorry for the delay 🙈

@matejcerny

Copy link
Copy Markdown
Author

Thanks for contribution. I'll take a look at it during the weekend. Sorry for the delay 🙈

No worries! I would really like to help more with Cellar, as there are quite a few places that could be improved. Also, it's currently the backbone of agentic programming in Scala, so I guess it deserves more love 🙂

@matejcerny

Copy link
Copy Markdown
Author

FYI I've already spent some time and tokens on:

  • HKT

    • previously def compose[G >: TypeLambda <: TypeLambda](evidence$1: Applicative[G]): Applicative[TypeLambda]
    • now def compose[G[_]](implicit evidence$1: Applicative[G]): Applicative[[α] =>> F[G[α]]]
  • Functions

    • previously p: Function1[A, Boolean]
    • now p: A => Boolean
  • Tuples

    • previously Tuple2[F[Boolean], F[A]]
    • now (F[Boolean], F[A])

I'll create separate PR's in case you agree that "this is the way" 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Symbol signatures diverge from README example

2 participants