trait Ord:
type Self
trait SemiGroup:
type Self
extension (x: Self) def combine(y: Self): Self
trait Monoid extends SemiGroup:
def unit: Self
object Monoid:
def unit[M](using m: Monoid { type Self = M}): M
trait Functor:
type Self[A]
extension [A](x: Self[A]) def map[B](f: A => B): Self[B]
trait Monad extends Functor:
def pure[A](x: A): Self[A]
extension [A](x: Self[A])
def flatMap[B](f: A => Self[B]): Self[B]
def map[B](f: A => B) = x.flatMap(f `andThen` pure)
def reduce[A: Monoid](xs: List[A]): A =
xs.foldLeft(Monoid.unit)(_ `combine` _)
trait ParserCombinator:
type Self
type Input
type Result
extension (self: Self)
def parse(input: Input): Option[Result] = ...
def combine[A: ParserCombinator, B: ParserCombinator { type Input = A.Input }] = ...
or
which is copied as
given Int is Ord ...
given Int is Monoid ...
type Reader = [X] =>> Env => X
given Reader is Monad ...
object Monoid:
def unit[M](using m: M is Monoid): M
Expectation
I would expect the code to show (and be copied) just as it was written in the markdown.
Either keep the indentation for all lines or remove the indentation from all lines by the same amount.
Compiler version
3.5.0
Minimized code
See for example https://github.com/scala/scala3/blob/5101daf9f454c23898ec205894a1c97025f39515/docs/_docs/reference/experimental/typeclasses.md?plain=1#L46-L80
or
https://github.com/scala/scala3/blob/5101daf9f454c23898ec205894a1c97025f39515/docs/_docs/reference/experimental/typeclasses.md?plain=1#L135-L144
Output
Which is copied as:
or
which is copied as
Expectation
I would expect the code to show (and be copied) just as it was written in the markdown. Either keep the indentation for all lines or remove the indentation from all lines by the same amount.