From 1432e138dabf1aa8d10c3bafc75d6ad9d85509f5 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 18 Jun 2023 12:06:57 +0200 Subject: [PATCH] Removing unused code and simplifying few dependencies --- build.sbt | 10 +--- .../src/main/scala/org/enso/data/List1.scala | 39 --------------- .../main/scala/org/enso/data/Shifted.scala | 48 ------------------- .../main/scala/org/enso/syntax/text/AST.scala | 23 --------- 4 files changed, 1 insertion(+), 119 deletions(-) delete mode 100644 lib/scala/syntax/definition/src/main/scala/org/enso/data/List1.scala delete mode 100644 lib/scala/syntax/definition/src/main/scala/org/enso/data/Shifted.scala diff --git a/build.sbt b/build.sbt index 33d6e19c6316..b11f117c5720 100644 --- a/build.sbt +++ b/build.sbt @@ -506,15 +506,7 @@ lazy val logger = (project in file("lib/scala/logger")) ) lazy val `syntax-definition` = - (project in file("lib/scala/syntax/definition")) - .dependsOn(logger) - .settings( - scalacOptions ++= Seq("-Ypatmat-exhaust-depth", "off"), - libraryDependencies ++= monocle ++ scalaCompiler ++ Seq( - "org.typelevel" %% "cats-core" % catsVersion, - "org.typelevel" %% "kittens" % kittensVersion - ) - ) + project in file("lib/scala/syntax/definition") lazy val syntax = (project in file("lib/scala/syntax/specialization")) .dependsOn(`syntax-definition`) diff --git a/lib/scala/syntax/definition/src/main/scala/org/enso/data/List1.scala b/lib/scala/syntax/definition/src/main/scala/org/enso/data/List1.scala deleted file mode 100644 index 202cb85285b2..000000000000 --- a/lib/scala/syntax/definition/src/main/scala/org/enso/data/List1.scala +++ /dev/null @@ -1,39 +0,0 @@ -package org.enso - -import cats.data.NonEmptyList - -package object data { - type List1[+T] = NonEmptyList[T] - object List1 { - def apply[T](el: T, tail: List[T]): List1[T] = new List1(el, tail) - def apply[T](el: T, tail: T*): List1[T] = new List1(el, tail.toList) - - def apply[T](list: List[T]): Option[List1[T]] = fromListOption(list) - - def unapply[T](t: List1[T]): Option[(T, List[T])] = Some((t.head, t.tail)) - - def fromListOption[T](lst: List[T]): Option[List1[T]] = lst match { - case Nil => None - case t :: ts => Some(List1(t, ts)) - } - - implicit class List1_ops[+T](lst: List1[T]) { - def mapInit[B >: T](f: T => B): List1[B] = - if (lst.tail.isEmpty) lst - else List1(f(lst.head), lst.tail.init.map(f) :+ lst.tail.last) - - def mapLast[B >: T](f: T => B): List1[B] = - if (lst.tail.isEmpty) List1(f(lst.head), lst.tail) - else List1(lst.head, lst.tail.init :+ f(lst.tail.last)) - - def intersperse[B >: T](t: B): List1[B] = - List1(lst.head, lst.tail.flatMap(s => List(t, s))) - - def +:[B >: T](that: List[B]): List1[B] = that match { - case Nil => lst - case s :: ss => List1(s, ss ++ lst.toList) - } - - } - } -} diff --git a/lib/scala/syntax/definition/src/main/scala/org/enso/data/Shifted.scala b/lib/scala/syntax/definition/src/main/scala/org/enso/data/Shifted.scala deleted file mode 100644 index d55de97c6e94..000000000000 --- a/lib/scala/syntax/definition/src/main/scala/org/enso/data/Shifted.scala +++ /dev/null @@ -1,48 +0,0 @@ -package org.enso.data - -import org.enso.data - -case class Shifted[+T](off: Int, wrapped: T) { - def map[S](f: T => S): Shifted[S] = - Shifted(off, f(wrapped)) -} - -object Shifted { - def apply[T](el: T): Shifted[T] = Shifted(0, el) - - case class List1[+T](head: T, tail: List[Shifted[T]]) { - def map[S](f: T => S): List1[S] = - List1(f(head), tail.map(_.map(f))) - - def toList(off: Int = 0): List[Shifted[T]] = - toList1(off).toList - - def toList1(off: Int = 0): data.List1[Shifted[T]] = - data.List1(Shifted(off, head), tail) - - def +:[B >: T](t: (Int, B)): List1[B] = - List1(t._2, Shifted(t._1, head) :: tail) - - def +:[B >: T](t: Shifted[B]): List1[B] = - List1(t.wrapped, Shifted(t.off, head) :: tail) - - def +[B >: T](that: List1[B]): List1[B] = - List1(head, tail ++ that.toList()) - - def +[B >: T](that: List[Shifted[B]]): List1[B] = - List1(head, tail ++ that) - - def :+[B >: T](that: Shifted[B]): List1[B] = - List1(head, tail :+ that) - } - - object List1 { - def apply[T](head: T): List1[T] = List1(head, Nil) - implicit def fromTuple[T](t: (T, List[Shifted[T]])): List1[T] = - List1(t._1, t._2) - - def fromListDropHead[T](lst: List[Shifted[T]]) = - List1(lst.head.wrapped, lst.tail) - } - -} diff --git a/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala b/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala index 5b5ce01b8a74..e2ab3fd35b4a 100644 --- a/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala +++ b/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala @@ -1,7 +1,5 @@ package org.enso.syntax.text -import cats.Monoid - //////////////////////////////////////////////////////////////////////////////// //// AbsolutePosition ////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -15,24 +13,3 @@ import cats.Monoid case class Location(start: Int, end: Int) { def length: Int = end - start } - -object Location { - implicit val optionSpanMonoid: Monoid[Option[Location]] = - new Monoid[Option[Location]] { - def empty: Option[Location] = None - - def combine( - x: Option[Location], - y: Option[Location] - ): Option[Location] = - x match { - case None => y - case Some(lSpan @ Location(lStart, _)) => - y match { - case None => Some(lSpan) - case Some(Location(_, rEnd)) => - Some(Location(lStart, rEnd)) - } - } - } -}