diff --git a/src/main/scala/just/fp/package.scala b/src/main/scala/just/fp/package.scala index 80ca6ea..8d26804 100644 --- a/src/main/scala/just/fp/package.scala +++ b/src/main/scala/just/fp/package.scala @@ -11,6 +11,8 @@ package object fp extends IdInstance { type Writer[L, V] = WriterT[Id, L, V] object Writer { - def apply[W, A](w: W, a: A): WriterT[Id, W, A] = WriterT[Id, W, A]((w, a)) + def apply[W, A](w: W, a: A): Writer[W, A] = Writer.writer((w, a)) + + def writer[W, A](wa: (W, A)): Writer[W, A] = WriterT[Id, W, A](wa) } } diff --git a/src/test/scala/just/fp/WriterTSpec.scala b/src/test/scala/just/fp/WriterTSpec.scala index e343c79..ea6e849 100644 --- a/src/test/scala/just/fp/WriterTSpec.scala +++ b/src/test/scala/just/fp/WriterTSpec.scala @@ -16,6 +16,7 @@ object WriterTSpec extends Properties { , property("testWriterFunctorLaws", WriterFunctorLaws.laws) , property("testWriterApplicativeLaws", WriterApplicativeLaws.laws) , property("testWriterMonadLaws", WriterMonadLaws.laws) + , property("test Writer(w, a) should be equal to Writer.writer((w, a))", testWriterApplyAndWriter) ) object WriterTFunctorLaws { @@ -98,4 +99,16 @@ object WriterTSpec extends Properties { , Gens.genAToMonadA(Gens.genIntToInt) ) } + + def testWriterApplyAndWriter: Property = for { + w <- Gens.genUnicodeString.log("w") + a <- Gens.genIntFromMinToMax.log("a") + wa = (w, a) + } yield { + val writer1 = Writer.writer(wa) + val writer2 = Writer(w, a) + + import just.fp.syntax._ + Result.diffNamed("=== Not Equal ===", writer1, writer2)(_ === _) + } }