Skip to content

Commit

Permalink
Core: fix pretty-printing of args
Browse files Browse the repository at this point in the history
  • Loading branch information
jiribenes committed Jan 22, 2025
1 parent b3ca299 commit 02c2ea4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions effekt/shared/src/main/scala/effekt/core/PrettyPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ object PrettyPrinter extends ParenPrettyPrinter {
def argsToDoc(targs: List[core.ValueType], vargs: List[core.Pure], bargs: List[core.Block]): Doc =
val targsDoc = if targs.isEmpty then emptyDoc else brackets(targs.map(toDoc))
//val cargsDoc = if cargs.isEmpty then emptyDoc else brackets(cargs.map(toDoc))
val vargsDoc = if vargs.isEmpty && !bargs.isEmpty then emptyDoc else vargs.map(toDoc)
val bargsDoc = bargs.map(toDoc)
targsDoc <> parens(vargsDoc) <> braces(bargsDoc)
val vargsDoc = if vargs.isEmpty && !bargs.isEmpty then emptyDoc else parens(vargs.map(toDoc))
val bargsDoc = if bargs.isEmpty then emptyDoc else braces(bargs.map(toDoc))
targsDoc <> vargsDoc <> bargsDoc

def paramsToDoc(tps: List[symbols.Symbol], vps: List[ValueParam], bps: List[BlockParam]): Doc = {
val tpsDoc = if (tps.isEmpty) emptyDoc else brackets(tps.map(toDoc))
tpsDoc <> parens(hsep(vps map toDoc, comma)) <> hcat(bps map toDoc)
val tpsDoc = if tps.isEmpty then emptyDoc else brackets(tps.map(toDoc))
val vpsDoc = if vps.isEmpty && !bps.isEmpty then emptyDoc else parens(vps.map(toDoc))
val bpsDoc = if bps.isEmpty then emptyDoc else hcat(bps.map(toDoc)) // already are in braces!
tpsDoc <> vpsDoc <> bpsDoc
}

def toDoc(instance: Implementation): Doc = {
Expand Down

0 comments on commit 02c2ea4

Please sign in to comment.