diff --git a/catculator-core/src/main/scala/pl/writeonly/catculator/core/adt/tree/BinaryTree.scala b/catculator-core/src/main/scala/pl/writeonly/catculator/core/adt/tree/BinaryTree.scala index a1e2530..aa8533e 100644 --- a/catculator-core/src/main/scala/pl/writeonly/catculator/core/adt/tree/BinaryTree.scala +++ b/catculator-core/src/main/scala/pl/writeonly/catculator/core/adt/tree/BinaryTree.scala @@ -1,11 +1,9 @@ package pl.writeonly.catculator.core.adt.tree -object BinaryTree { - - case class Leaf[A](leaf: A) extends BinaryTree[A] +enum BinaryTree[+A]: + case Leaf(leaf: A) + case Node(first: BinaryTree[A], follow: BinaryTree[A]) - case class Node[A](first: BinaryTree[A], follow: BinaryTree[A]) - extends BinaryTree[A] +object BinaryTree { } - -sealed trait BinaryTree[+A] +q \ No newline at end of file diff --git a/catculator-core/src/main/scala/pl/writeonly/catculator/core/adt/tree/Tree.scala b/catculator-core/src/main/scala/pl/writeonly/catculator/core/adt/tree/Tree.scala index 2432209..418c5a3 100644 --- a/catculator-core/src/main/scala/pl/writeonly/catculator/core/adt/tree/Tree.scala +++ b/catculator-core/src/main/scala/pl/writeonly/catculator/core/adt/tree/Tree.scala @@ -2,13 +2,11 @@ package pl.writeonly.catculator.core.adt.tree import cats.data.NonEmptyList +enum Tree[A]: + case Leaf(leaf: A) + case Node(children: NonEmptyList[Tree[A]]) + object Tree { def node[A](head: Tree[A], tail: Tree[A]*): Tree[A] = Node(NonEmptyList(head, tail.toList)) - - case class Leaf[A](leaf: A) extends Tree[A] - - case class Node[A](children: NonEmptyList[Tree[A]]) extends Tree[A] } - -sealed trait Tree[+A]