Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traverse lesson, running examples with cats 1.0.0-MF #63

Open
Fabs opened this issue Nov 12, 2017 · 0 comments
Open

Traverse lesson, running examples with cats 1.0.0-MF #63

Fabs opened this issue Nov 12, 2017 · 0 comments

Comments

@Fabs
Copy link

Fabs commented Nov 12, 2017

Hello people :).

I am trying to run the following code on a scala worksheet scala 2.12.4, sbt 1.0.3, cats 1.0.0-MF:

import cats.Semigroup
import cats.data.{NonEmptyList, OneAnd, Validated, ValidatedNel}
import cats.implicits._

implicit def nelSemigroup[A]: Semigroup[NonEmptyList[A]] =
  OneAnd.oneAndSemigroupK[List].algebra[A]

def parseIntEither(s: String): Either[NumberFormatException, Int] =
  Either.catchOnly[NumberFormatException](s.toInt)

def parseIntValidated(s: String): ValidatedNel[NumberFormatException, Int] =
  Validated.catchOnly[NumberFormatException](s.toInt).toValidatedNel

List("1", "2", "3").traverseU(parseIntEither)
List("1", "abc", "3").traverseU(parseIntEither)

But OneAnd apparently does not have oneAndSemigroupK, and I was also not able to find this in the scaladoc for cats. Maybe it is obvious, but I don't now how to implement the implicit so my List will have traverseU

Error is:

Error:(6, 11) value oneAndSemigroupK is not a member of object cats.data.OneAnd
  OneAnd.oneAndSemigroupK[List].algebra[A]
         ^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant