Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Colt Frederickson
@coltfred
I tried to make a
lazy val root = project
  .in(file("."))
  .aggregate(catsScalatest.jvm, catsScalatest.js)
  .settings(
    publish := {},
    publishLocal := {}
  )
which didn't fix it either.
Colt Frederickson
@coltfred
BTW, it's 2.12 JVM that doesn't compile. Everything else works.
Brian P. Holt
@bpholt
yeah I'm able to reproduce that
Colt Frederickson
@coltfred
@bpholt Figured out that if I moved the code into shared and use CrossType.Full it works.
Maybe when you don't have modules you have to do it that way or something.
sbt, always :confounded: me...
Brian P. Holt
@bpholt
🤷‍♂️
elyphas
@elyphas
What would be the imports so I can use toNonEmptyList
I have an error:
value toNonEmptyList; is not a member of List[spatutorial.shared.comparativostypes.QryRow]?
I have no problem with toNel but I would rather to work with a NonEmptyList and not Option[NonemptyList], because I feel NonEmptyList fit better into my problem
by the way, my imports are:
import cats._
import cats.data._
import cats.implicits._
Paul Snively
@paul-snively
@elyphas: You can't go straight from a List to a NonEmptyList, because the List may be empty.
@elyphas: If you happen to know the List can not be empty, you can just use the NonEmptyList constructor with the head and tail of the List.
elyphas
@elyphas
@paul-snively ; ah, I don't know if List will be an NonEmptyList or at least when.
Thank You.
Paul Snively
@paul-snively
@elyphas: Certainly. Usually, it turns out it doesn't matter, in the sense that the empty List case is accounted for anyway, e.g. by traverse or fold or whatever.
Diego E. Alonso Blas
@diesalbla
Good evening! Who has some experience with MIMA around here?
elyphas
@elyphas
@paul-snively ; Oh, :) awesome
Paul Snively
@paul-snively
@elyphas: e.g. List.empty[IO[Int]].sequence.
@elyphas: Gives you a perfectly fine IO[List[Int]].
@elyphas: (That, when run, gives you a perfectly lovely empty List[Int].)
@elyphas: Similarly, List.empty[Int].foldLeft(0)(_ + _)
@elyphas: That gives you 0, as it should.
elyphas
@elyphas
ah, :)
elyphas
@elyphas
cool
until now, I Understood
Paul Snively
@paul-snively
@elyphas: General rule of thumb: avoid overusing pattern-matching. See if the type you're working with supports fold or some variant of it, or traverse and sequence from Cats.
elyphas
@elyphas
@paul-snively ; Thank you, I was thinking at this moment in pattern matching, :)
Paul Snively
@paul-snively
@elyphas: For example, Option and Either both support fold. Lists support fold, foldLeft, and foldRight. All of them have Traverse instances, and so support traverse and sequence.
elyphas
@elyphas
ah ok.
thats my problem now,
I have this error:
found   : outwatch.reactive.SinkObserver[(spatutorial.shared.comparativostypes.ViewProcess, cats.data.NonEmptyList[(spatutorial.shared.comparativostypes.QryRow, spatutorial.shared.comparativostypes.Comparative)], Double)]
[error]  required: F[_ >: (spatutorial.shared.comparativostypes.ViewProcess, Option[cats.data.NonEmptyList[(spatutorial.shared.comparativostypes.QryRow, spatutorial.shared.comparativostypes.Comparative)]], Double)]
Paul Snively
@paul-snively
@elyphas: Pattern-matching is regrettably seductive, but it can lead pretty quickly to treating e.g. "empty" as a special case, when it really isn't.
elyphas
@elyphas
I had that kind of problem, :)
my function:
def print(gralData: ViewProcess, comparatives: NonEmptyList[(QryRow, Comparative)], minimosRetenISR: Double) = {
i call it this way:
storeComparative.store.filter{ case (action, state@_) =>
          action match {
              case storeComparative.UpdateTenders(comparative@_) => true
              case _ => false
        }}.map { case (action@_, state) =>
        (state.gralData, state.comparative.toNel, state.minimosRetensionISR)
      }
    ) --> printComparative
@paul-snively ; Any idea?
:)
I need to convert to Option[NonEmptyList[T]] but at the same time I want to convert only to NonEmptyList[T]
so I wast thinking in pattern matching:
Paul Snively
@paul-snively
@elyphas: With respect to the error, I think (at least) print needs just take a List, and remove the toNel above.
@elyphas: Didn't you say you don't know state.comparative can't be empty?
elyphas
@elyphas
:)
sorry.
Paul Snively
@paul-snively
@elyphas: No problem. Just trying to get to the right model.
elyphas
@elyphas
I was working that way, but I wanted to avoid future empty list, so I put my print' parameterNonEmptyList`
thank you
Paul Snively
@paul-snively
If you know your List can't possibly be empty, then you can justify NonEmptyList(myList.head, myList.tail).
The point beingmyList.head is unsafe.
elyphas
@elyphas
ah
elyphas
@elyphas
@paul-snively ; thank you very much.
Paul Snively
@paul-snively
@elyphas: Sure!