Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mio-19 committed Dec 30, 2024
1 parent 8728195 commit 1762b92
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/chester/core/parseCheckTAST.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def parseCheckTAST(
module = DefaultModule,
ast = BlockTerm(Vector.empty, UnitTerm_(meta = None), meta = None),
ty = UnitType(meta = None),
effects = NoEffect,
effects = Effects.Empty,
problems = SeverityMap.Empty.copy(error = true)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ class FilesTyckTest extends FunSuite {
case TyckResult.Success(result, _, _) =>
if (result.collectMeta.isEmpty) {
println(s"Testing read/write for $inputFile")
assertEquals(read[Judge](write[Judge](result)), result)
assertEquals(readBinary[Judge](writeBinary[Judge](result)), result)
assertEquals(StringPrinter.render(read[Judge](write[Judge](result)))(using
PrettierOptions.Default
), StringPrinter.render(result)(using
PrettierOptions.Default
))
assertEquals(StringPrinter.render(readBinary[Judge](writeBinary[Judge](result)))(using
PrettierOptions.Default
), StringPrinter.render(result)(using
PrettierOptions.Default
))
assertEquals(
StringPrinter.render(convertToSimple(result.wellTyped))(using
PrettierOptions.Default
Expand Down
5 changes: 4 additions & 1 deletion syntax/jvm/src/main/scala/chester/syntax/core/truffle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ object truffle {
case class FunctionType(
@const telescope: Vector[TelescopeTerm],
@child var resultTy: Term,
@const effects: EffectsM = NoEffect,
@const effects: EffectsM = Effects.Empty,
@const meta: OptionTermMeta
) extends WHNF
with FunctionTypeC[Term] {
Expand Down Expand Up @@ -314,6 +314,9 @@ object truffle {
override type ThisTree = Effects
override def cons: EffectsF[Term, ThisTree] = this.copy
}
object Effects {
val Empty = Effects(Map.empty, meta = None)
}
case class ExceptionEffect(@const meta: OptionTermMeta) extends Effect with ExceptionEffectC[Term] {
override type ThisTree = ExceptionEffect
override def cons: ExceptionEffectF[Term, ThisTree] = this.copy
Expand Down
7 changes: 6 additions & 1 deletion syntax/shared/src/main/scala/chester/syntax/core/Judge.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package chester.syntax.core
import chester.doc.const.Docs
import chester.uniqid.*
import chester.utils.doc.*
import upickle.default.*

case class Judge(wellTyped: Term, ty: Term, effects: Effects = NoEffect) extends ContainsUniqid derives ReadWriter {
case class Judge(wellTyped: Term, ty: Term, effects: Effects = Effects.Empty) extends ContainsUniqid with ToDoc derives ReadWriter {
def substitute(from: TermWithUniqid, to: Term): Judge = Judge(
wellTyped.substitute(from, to),
ty.substitute(from, to),
Expand All @@ -27,4 +29,7 @@ case class Judge(wellTyped: Term, ty: Term, effects: Effects = NoEffect) extends
effects.replaceU(reranger).asInstanceOf[Effects]
)
}

override def toDoc(using options: PrettierOptions): Doc =
Docs.`(` <> wellTyped.toDoc <> Docs.`,` <> ty.toDoc <> Docs.`,` <> effects.toDoc <> Docs.`)`
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,16 @@ object simple {
case class FunctionType(
telescope: Vector[TelescopeTerm],
resultTy: Term,
effects: EffectsM = NoEffect,
effects: EffectsM = Effects.Empty,
meta: OptionTermMeta
) extends WHNF
with FunctionTypeC[Term] {
override type ThisTree = FunctionType
override def cons: FunctionTypeF[Term, ThisTree] = FunctionType(_,_,_,_)
}
object Effects {
val Empty = Effects(Map.empty, meta = None)
}
case class ObjectClauseValueTerm(
key: Term,
value: Term,
Expand Down
6 changes: 0 additions & 6 deletions syntax/shared/src/main/scala/chester/syntax/core/utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ object UnitTerm_ {

}

object Effects_ {
val Empty: Effects = Effects(HashMap.empty, meta = None)
}

val NoEffect = Effects_.Empty

object AbstractIntTerm_ {
def from(value: BigInt, meta: OptionTermMeta): AbstractIntTerm =
if (value.isValidInt) IntTerm(value.toInt, meta)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tyck/src/main/scala/chester/tyck/Elaborater.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait Elaborater extends ProvideCtx with ElaboraterCommon {
// Create a new type cell representing the kind Typeω (the type of types)
val kindType = literal(Typeω: Term)

elab(expr, kindType, toEffectsCell(NoEffect))
elab(expr, kindType, toEffectsCell(Effects.Empty))
}

def checkTypeId(expr: Expr)(using
Expand Down

0 comments on commit 1762b92

Please sign in to comment.