Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
auht committed Sep 27, 2024
1 parent bbd8f9b commit 4f21762
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
11 changes: 3 additions & 8 deletions shared/src/main/scala/mlscript/TyperDatatypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ abstract class TyperDatatypes extends TyperHelpers { Typer: Typer =>
}
}
def updateOn(index: Int, bound: ST)(implicit raise: Raise, ctx: Ctx) : Unit = {
println(s"TSC update: $tvs in $constraints")
updateImpl(index, bound)
println(s"TSC update: $tvs in $constraints")
}
Expand Down Expand Up @@ -759,8 +758,7 @@ abstract class TyperDatatypes extends TyperHelpers { Typer: Typer =>
S(List((pol, first) -> rest))
else N
}
def lcgFunction(pol: Bool, first: FT, rest: FT)
(implicit ctx: Ctx)
def lcgFunction(pol: Bool, first: FT, rest: FT)(implicit ctx: Ctx)
: Opt[Ls[(Bool, ST) -> ST]] = {
for {
lm <- lcg(!pol, first.lhs, rest.lhs)
Expand All @@ -779,11 +777,8 @@ abstract class TyperDatatypes extends TyperHelpers { Typer: Typer =>
val tvs = u.flatMap(_.keys).distinct
val m = tvs.map(x => u.map(_.getOrElse(x,if (x._1) TopType else BotType)))
val tsc = new TupleSetConstraints(m.transpose, tvs)
tvs.mapValuesIter(_.unwrapProxies).zipWithIndex.foreach {
case ((true, tv: TV), i) =>
tv.tsc.updateWith(tsc)(_.map(_ + i).orElse(S(Set(i))))
case ((false, tv: TV), i) =>
tv.tsc.updateWith(tsc)(_.map(_ + i).orElse(S(Set(i))))
tvs.values.map(_.unwrapProxies).zipWithIndex.foreach {
case (tv: TV, i) => tv.tsc.updateWith(tsc)(_.map(_ + i).orElse(S(Set(i))))
case _ => ()
}
println(s"TSC mk: ${tsc.tvs} in ${tsc.constraints}")
Expand Down
5 changes: 2 additions & 3 deletions shared/src/main/scala/mlscript/TyperHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -956,12 +956,11 @@ abstract class TyperHelpers { Typer: Typer =>
def getVars: SortedSet[TypeVariable] = getVarsImpl(includeBounds = true)

def showBounds: String =
getVars.iterator.filter(tv => (tv.assignedTo.nonEmpty || (tv.upperBounds ++ tv.lowerBounds).nonEmpty)).map {
getVars.iterator.filter(tv => tv.assignedTo.nonEmpty || (tv.upperBounds ++ tv.lowerBounds).nonEmpty).map {
case tv @ AssignedVariable(ty) => "\n\t\t" + tv.toString + " := " + ty
case tv => ("\n\t\t" + tv.toString
+ (if (tv.lowerBounds.isEmpty) "" else " :> " + tv.lowerBounds.mkString(" | "))
+ (if (tv.upperBounds.isEmpty) "" else " <: " + tv.upperBounds.mkString(" & "))
)
+ (if (tv.upperBounds.isEmpty) "" else " <: " + tv.upperBounds.mkString(" & ")))
}.mkString + {
val visited: MutSet[TupleSetConstraints] = MutSet.empty
getVars.iterator.flatMap(_.tsc).map { case (tsc, i) =>
Expand Down

0 comments on commit 4f21762

Please sign in to comment.