Skip to content

Commit

Permalink
Added alleycats.Pure as it started working
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszKubuszok committed Sep 11, 2019
1 parent 0c14adb commit 65f5923
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Test("1").map(_.toInt) // Test(1)
`cats.Eq`, `cats.PartialOrder`, `cats.Order`,
`cats.Functor`, `cats.Foldable`, `cats.Traverse`, `cats.Show`, `cats.derived.ShowPretty`,
`cats.Monoid`, `cats.MonoidK`, `cats.Semigroup`, `cats.SemigroupK`,
`alleycats.Empty`.
`alleycats.Empty`, `alleycats.Pure`.

## Internals

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.scalaland.catnip

import cats.implicits._
import alleycats.std.all._

import org.specs2.mutable.Specification

class SemiSpec extends Specification {
Expand Down Expand Up @@ -140,6 +142,7 @@ class SemiSpec extends Specification {
}

/*
// TODO: https://github.com/scalalandio/catnip/issues/9
"generate for cats.Hash" in {
// given
@Semi(cats.Hash) final case class TestHash(a: String)
Expand All @@ -151,7 +154,7 @@ class SemiSpec extends Specification {
// then
result1 must not(beEqualTo(result2))
}
*/
*/

@Semi(cats.Functor) final case class TestFunctor[A](a: A, b: A)
"generate for cats.Functor" in {
Expand Down Expand Up @@ -298,5 +301,18 @@ class SemiSpec extends Specification {
// then
result must beEqualTo(TestEmpty(""))
}

@Semi(alleycats.Pure) final case class TestPure[A](a: A)
"generate for alleycats.Pure" in {
// given
// test class moved outside as a workaround for error in 2.11:
// can't existentially abstract over parameterized type TestPure[String]

// when
val result = alleycats.Pure[TestPure].pure("")

// then
result must beEqualTo(TestPure(""))
}
}
}
1 change: 1 addition & 0 deletions modules/catnip/src/main/resources/derive.semi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ cats.MonoidK=cats.derived.semi.monoidK
cats.kernel.Semigroup=cats.derived.semi.semigroup
cats.SemigroupK=cats.derived.semi.semigroupK
alleycats.Empty=cats.derived.semi.empty
alleycats.Pure=cats.derived.semi.pure,shapeless.Typeable
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.scalaland.catnip

import cats.derived.MkHash
import cats.Hash
import shapeless.OrElse

package object internals {

type PotentiallyDerivedHash[A] = Hash[A] OrElse MkHash[A]
}
11 changes: 11 additions & 0 deletions modules/catnip/src/main/scala/io/scalaland/catnip/package.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.scalaland

import cats.derived.MkHash
import cats.Hash
import shapeless.OrElse

package object catnip {

// workaround for missing implicits in kittens derivation
type PotentiallyDerivedHash[A]=Hash[A] OrElse MkHash[A]
}
2 changes: 1 addition & 1 deletion readme/Readme.scalatex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
@code{cats.Eq}, @code{cats.PartialOrder}, @code{cats.Order},
@code{cats.Functor}, @code{cats.Foldable}, @code{cats.Traverse}, @code{cats.Show},
@code{cats.derived.ShowPretty}, @code{cats.Monoid}, @code{cats.MonoidK},
@code{cats.Semigroup}, @code{cats.SemigroupK}, @code{alleycats.Empty}.
@code{cats.Semigroup}, @code{cats.SemigroupK}, @code{alleycats.Empty}, @code{alleycats.Pure}.

@sect{Internals}
@p
Expand Down

0 comments on commit 65f5923

Please sign in to comment.