Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
mio-19 committed Oct 27, 2024
1 parent b087a24 commit 513be86
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions syntax/src/main/scala/chester/syntax/core/Term.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ case class CallingArgTerm(
vararg: Boolean = false,
meta: OptionTermMeta
) extends WHNF
with CallingArgTermC[Term]
derives ReadWriter {
with CallingArgTermC[Term] derives ReadWriter {
override def cons: CallingArgTermF[Term, ThisTree] = this.copy
override type ThisTree = CallingArgTerm
override def descent(f: Term => Term, g: TreeMap[Term]): CallingArgTerm =
Expand Down Expand Up @@ -106,8 +105,7 @@ case class Calling(
implicitly: Boolean = false,
meta: OptionTermMeta
) extends WHNF
with CallingC[Term]
derives ReadWriter {
with CallingC[Term] derives ReadWriter {
override type ThisTree = Calling
override def cons: CallingF[Term, ThisTree] = this.copy
override def descent(f: Term => Term, g: TreeMap[Term]): Calling =
Expand Down Expand Up @@ -1105,8 +1103,7 @@ case class ObjectClauseValueTerm(
value: Term,
meta: OptionTermMeta
) extends WHNF
with ObjectClauseValueTermC[Term]
derives ReadWriter {
with ObjectClauseValueTermC[Term] derives ReadWriter {
override type ThisTree = ObjectClauseValueTerm
override def cons: ObjectClauseValueTermF[Term, ThisTree] = this.copy

Expand Down Expand Up @@ -1722,8 +1719,7 @@ case class BlockTerm(
result: Term,
meta: OptionTermMeta
) extends Uneval
with BlockTermC[Term]
derives ReadWriter {
with BlockTermC[Term] derives ReadWriter {
override type ThisTree = BlockTerm
override def cons: BlockTermF[Term, ThisTree] = this.copy

Expand Down Expand Up @@ -1762,7 +1758,7 @@ trait AnnotationC[Rec <: TermT[Rec]] extends UnevalT[Rec] {
cpy(
term = f(term),
ty = ty.map(f),
effects = effects.map(x=>g(x).asInstanceOf[EffectsM])
effects = effects.map(x => g(x).asInstanceOf[EffectsM])
)
)
}
Expand Down Expand Up @@ -1828,8 +1824,7 @@ case class FieldTerm(
ty: Term,
meta: OptionTermMeta
) extends WHNF
with FieldTermC[Term]
derives ReadWriter {
with FieldTermC[Term] derives ReadWriter {
override type ThisTree = FieldTerm
override def cons: FieldTermF[Term, ThisTree] = this.copy

Expand All @@ -1853,7 +1848,13 @@ sealed trait TypeDefinition extends StmtTerm with TermWithUniqid with TypeDefini

@FunctionalInterface
trait RecordStmtTermF[Rec <: TermT[Rec], ThisTree <: RecordStmtTermC[Rec]] {
def apply(name: Name, uniqId: UniqidOf[RecordStmtTermC[Rec]], fields: Vector[FieldTermC[Rec]], body: Option[BlockTermC[Rec]], meta: OptionTermMeta): ThisTree
def apply(
name: Name,
uniqId: UniqidOf[RecordStmtTermC[Rec]],
fields: Vector[FieldTermC[Rec]],
body: Option[BlockTermC[Rec]],
meta: OptionTermMeta
): ThisTree
}

trait RecordStmtTermC[Rec <: TermT[Rec]] extends TypeDefinitionT[Rec] with StmtTermT[Rec] {
Expand All @@ -1863,7 +1864,8 @@ trait RecordStmtTermC[Rec <: TermT[Rec]] extends TypeDefinitionT[Rec] with StmtT
def fields: Vector[FieldTermC[Rec]]
def body: Option[BlockTermC[Rec]]
def cons: RecordStmtTermF[Rec, ThisTree]
override def toTerm: RecordStmtTerm = RecordStmtTerm(name, uniqId.asInstanceOf[UniqidOf[RecordStmtTerm]], fields.map(_.toTerm), body.map(_.toTerm), meta)
override def toTerm: RecordStmtTerm =
RecordStmtTerm(name, uniqId.asInstanceOf[UniqidOf[RecordStmtTerm]], fields.map(_.toTerm), body.map(_.toTerm), meta)

override def toDoc(using options: PrettierOptions): Doc = {
val fieldsDoc = fields.map(_.toDoc).reduceOption(_ <> Doc.text(", ") <> _).getOrElse(Doc.empty)
Expand All @@ -1876,7 +1878,13 @@ trait RecordStmtTermC[Rec <: TermT[Rec]] extends TypeDefinitionT[Rec] with StmtT
)
}

def cpy(name: Name = name, uniqId: UniqidOf[RecordStmtTermC[Rec]] = uniqId, fields: Vector[FieldTermC[Rec]] = fields, body: Option[BlockTermC[Rec]] = body, meta: OptionTermMeta = meta): ThisTree =
def cpy(
name: Name = name,
uniqId: UniqidOf[RecordStmtTermC[Rec]] = uniqId,
fields: Vector[FieldTermC[Rec]] = fields,
body: Option[BlockTermC[Rec]] = body,
meta: OptionTermMeta = meta
): ThisTree =
cons.apply(name, uniqId, fields, body, meta)

override def descent(f: Rec => Rec, g: TreeMap[Rec]): Rec = thisOr(
Expand Down Expand Up @@ -2024,4 +2032,4 @@ case class ObjectTypeTerm(
override def descent(f: Term => Term, g: TreeMap[Term]): ObjectTypeTerm = thisOr(
copy(objectDef = g(objectDef))
)
}
}

0 comments on commit 513be86

Please sign in to comment.