From bc7c025467424af4fdd0df1bdd01c21fc36f899b Mon Sep 17 00:00:00 2001 From: zhongl Date: Fri, 13 Sep 2024 22:24:44 +0800 Subject: [PATCH] Clean code. --- src/core/Gauge.scala | 5 ----- src/core/Page.scala | 13 +++++++++++++ src/core/package.scala | 13 ++++--------- 3 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 src/core/Page.scala diff --git a/src/core/Gauge.scala b/src/core/Gauge.scala index b3e471c..dbd1186 100644 --- a/src/core/Gauge.scala +++ b/src/core/Gauge.scala @@ -17,8 +17,3 @@ object Gauge: type BeatPerMinute = BeatPerMinute.type type StepPerMinute = StepPerMinute.type type Pace = Pace.type - -trait Distance -trait Duration -trait Timestamp -trait Box diff --git a/src/core/Page.scala b/src/core/Page.scala new file mode 100644 index 0000000..bdaa58f --- /dev/null +++ b/src/core/Page.scala @@ -0,0 +1,13 @@ +package core + + +trait Page[A] extends (Mutation => Option[Mutation]) + +object Page: + given any: Page[EmptyTuple] = Some(_) + + given tuple[H, T <: Tuple](using h: Page[H], t: Page[T]): Page[H *: T] = + a => h(a).flatMap(t) + + def apply[A](using pa: Page[A]) = pa +end Page \ No newline at end of file diff --git a/src/core/package.scala b/src/core/package.scala index 390702c..ee9ca32 100644 --- a/src/core/package.scala +++ b/src/core/package.scala @@ -10,15 +10,10 @@ extension [A](a: A) inline def single: NonEmpty[A] = a -> List.empty[A] type Interval[A] = NonEmpty[A] type History[A] = NonEmpty[Interval[A]] -trait Page[A] extends (Mutation => Option[Mutation]) -object Page: - given any: Page[EmptyTuple] = Some(_) - - given tuple[H, T <: Tuple](using h: Page[H], t: Page[T]): Page[H *: T] = - a => h(a).flatMap(t) - - def apply[A](using pa: Page[A]) = pa -end Page +sealed trait Distance +sealed trait Duration +sealed trait Timestamp +sealed trait Box type Injection[A] = (HTMLElement, A) trait Inject[A] extends (Injection[A] => Unit):