Skip to content

Commit

Permalink
mapN to Apply syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefanos Stefanou committed Nov 2, 2023
1 parent ee7feac commit 70f0cbc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/main/scala/mycats/examples/ValidatedExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import mycats.examples.common.Expense
import mycats.examples.common.Utils.NonEmptyList
import mycats.instances.ValidatedInstances.validatedApplicativeErrorInstance
import mycats.lib.obj.Semigroup
import mycats.lib.syntax.SemigroupalSyntax
import mycats.lib.syntax.TupleCombineOps.Tuple2SemigroupalOps
import mycats.lib.syntax.ApplySyntax.Tuple2ApplyOps
object ValidatedExample {
type ValidatedNel[A] = Validated[NonEmptyList[String],A]
val validatedNelInstance = validatedApplicativeErrorInstance[NonEmptyList[String],Long]
Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/mycats/lib/syntax/ApplySyntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ object ApplySyntax {
def productN[B](fb:F[B])(implicit semigroupalF:Semigroupal[F]) = semigroupalF.product(fa,fb)
def productN[B,C](fb:F[B],fc:F[C])(implicit apply:Apply[F]) = apply.product2(fa,fb,fc)
}
implicit class Tuple2ApplyOps[F[_],A,B](ab:Tuple2[F[A],F[B]]){
def mapN[C](f:Tuple2[A,B]=>C)(implicit apply:Apply[F]): F[C] =
apply.map[(A,B),C](apply.product[A,B](ab._1,ab._2))(f)
}
}
11 changes: 0 additions & 11 deletions src/main/scala/mycats/lib/syntax/TupleCombineOps.scala

This file was deleted.

1 change: 1 addition & 0 deletions ~$diagram.drawio.dtmp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="Electron" modified="2023-11-02T11:27:59.219Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/18.0.0 Chrome/100.0.4896.143 Electron/18.2.0 Safari/537.36" etag="G3_QTsZ_rxluL4svFRvZ" version="18.0.0" type="device" pages="2"><diagram id="tPDxc9v9lSpUtl4Dx5MV" name="Initial Big Picture">7V1bd5u4Fv4t58Gr7QNdXH15tJ2k7TQ502l6pk1fZskg25oAokKO4/n1RwKBAcnEjcHYnayuJiAJIb590dbW3krPmgaP7wiIljfYg37P1L3HnnXRM03T1gfsFy/ZZCX8lpcsCPLSMmNbcIv+gaJQF6Ur5MG41JBi7FMUlQtdHIbQpaUyQAhel5vNsV9+awQWUCq4dYEvl35FHl2mpUNzsC1/D9Fimb3Z6I/SmgBkjcWXxEvg4XWhyLrsWVOCMU2vgscp9Dl6GS7pc1c7avOBERjSfR748vHj17sf8e0P76u+jvHk9mpwrVlpLw/AX4kPFoOlmwwBglehB3knRs+arJeIwtsIuLx2zYjOypY08EW1PCgxzgdIKHwsFIlBvoM4gJRsWBNRqzmWkz4jeEbrCwTXWwIYo75otCyi74iWQFB9kfe+BYZdCGzUOH3/sunfTQdu4MJP5GN0P12OV5oxPAegnKESKV1GiklmS0g55wCUZe/LUuawAaBu7z6vvk/f3V/a3+765uz7DVoONWPUMFJzHFKhQA2zGeSsjHcEcI4j42YNVfxlOm3B1rQktgCbZlZhczqHbXAGsFXldLSvlNpNqDMlbkMJJegxA0HcYkKXeIFD4F9uSydbHHV2t21zjXEk0PsbUroR8IEVxWVs4SOi3wrXd7yrt464u3gUPSc3m+wmZJ/7rXhTeIrfbh9L7rLndtItxiviwhpoBANRQBaQ1rSz03Yct1ouINAHFD2UDa/GCTp6IeihBHW6IqjaNLO6pKj+HIoaZYoOjkpSNYjGSQmpKU1WN4w6Xs/s++wrJjPCrhb86nW0IpC9Ys5GdQOiNzVzmr7HnIZ8f4p9TJJnLc+BQ89m5TEl+B4WaobmzOr3G7Kx9LKxkC99i7OeqTAW+g3MeZ++/3bnfwmcf36/iG/7s4s//qePNUNC8cxUpNmeQFmyQH34Nlp//u3Pq6vNh8mm/4OQOGQCpZ+UQMn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rX88eihM0xQliXWWQgvFSxzht7Fk6Jw0tkg/kKwgH5AtDk7YItds4/MuflW+NGJjOnqJ7xgtQ/xKfOP3Zt2xbV1ZSujy8b0b+a7hTiy4n8sNHLsENoT8LwRuCh8P82g0xDwKXGNuF9DjfLcuEw27vxjKkXvK9sVt+D0hLoO0+zM5sK9N11UldpfjZuzezfaVq2HME6L5hl0O6dg9afvC1iN9q9QlHdNj97jta98TEZwSDSCRfy0ytlTkco7riXvi9vVvSpJnId2/3px+Er/lowRUu5flfVvvfT68/QM=</diagram></mxfile>

0 comments on commit 70f0cbc

Please sign in to comment.