diff --git a/core/src/main/scala/kuram/syntax/all.scala b/core/src/main/scala/kuram/syntax/all.scala index 61963b7..2eb01c9 100644 --- a/core/src/main/scala/kuram/syntax/all.scala +++ b/core/src/main/scala/kuram/syntax/all.scala @@ -35,4 +35,5 @@ private[syntax] trait AllSyntax with MonoidSyntax with SemigroupSyntax with SemigroupalSyntax + with SemigroupKSyntax with AlternativeSyntax diff --git a/core/src/main/scala/kuram/syntax/package.scala b/core/src/main/scala/kuram/syntax/package.scala index 69cd37b..ed13621 100644 --- a/core/src/main/scala/kuram/syntax/package.scala +++ b/core/src/main/scala/kuram/syntax/package.scala @@ -35,5 +35,6 @@ package object syntax { object applicative extends ApplicativeSyntax object flatmap extends FlatMapSyntax object monad extends MonadSyntax + object semigroupk extends SemigroupKSyntax object alternative extends AlternativeSyntax } diff --git a/core/src/main/scala/kuram/syntax/semigroupk.scala b/core/src/main/scala/kuram/syntax/semigroupk.scala new file mode 100644 index 0000000..b8e15e3 --- /dev/null +++ b/core/src/main/scala/kuram/syntax/semigroupk.scala @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 lamdalib + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package kuram +package syntax + +import kuram.kinds.SemigroupK + +private[syntax] trait SemigroupKSyntax { + extension [F[_], A](a: F[A])(using SemigroupK[F]) { + final def combineK(b: F[A]): F[A] = { + SemigroupK[F].combineK(a, b) + } + + final def <+>(b: F[A]): F[A] = { + combineK(b) + } + } +}