These are chat archives for typelevel/cats

27th
Jul 2016
Cody Allen
@ceedubs
Jul 27 2016 00:08
@dozed oh hmm interesting. I haven’t looked into scala native yet. I’m not aware of the limitations
Adelbert Chang
@adelbertc
Jul 27 2016 04:56
@tpolecat do you object to both the existence of pureEval as well as a by-name point like in Scalaz due to sketchy effect-capture usage?
preferring isntead to put effect capture directly on something like, say, IO (or some other data type)
since like yo usaid effect capture is sketchy
Rob Norris
@tpolecat
Jul 27 2016 05:13
@adelbertc as far as I can tell the use-case for by-name point is kind of marginal; the purpose is to prevent nontermination when constructing recursive structures but I have never seen an example where it matters. I asked on #scalaz and S11 said maybe something with MonadRec but was also unable to offer a straightforward example.
For data types that truly capture effects I see this as a very special operation, a kind of FFI into the impure part of the language. In principle there should be only one such data type (IO) but in our world there are a handful. Abstracting over this operation is super sketchy and needs to be done with great care, not with an innocuous looking thing like pureEval (or by-name point).
/end sermon
Adelbert Chang
@adelbertc
Jul 27 2016 05:19
sounds good :+1:
was sort of confused at first at earlier comments but had a sudden realization after dinner, thouhgt id double check
but makes sense to me
Pere Villega
@pvillega
Jul 27 2016 07:56

Hi! Sorry to disturb, I have a question regarding Foldable.foldK. I'm going through the exercises at https://www.scala-exercises.org/cats/foldable and there is this one line:

Foldable[List].foldK(List(None, Option("two"), Option("three"))) should be(Option("two"))

What confuses me is that if we use a Monoid instance to combine the elements, the result would be Option("twothree"). Why does MonoidK drop Option("three") from the combination?

Merlin Göttlinger
@mgttlinger
Jul 27 2016 08:00
Because MonoidKdoes not rely on there being a Monoid for the contained type and therefore implements the combine/append as just taking the second parameter as result.
Pere Villega
@pvillega
Jul 27 2016 08:04
it may be a silly question, but... why? (besides implementation) Isn't MonoidK a type of Monoid and as such shouldn't it append stuff together, or am I missing something very obvious?
Merlin Göttlinger
@mgttlinger
Jul 27 2016 08:08
Well you can only combine two Some[A] if you know how to combine two A aka you have a Semigroupfor them. If you have that you also have a Monoid[Option[A]] If you do not have that you have to take one or the other which may or may not be helpful for what you want to do. The "why?" is explained here a bit: https://github.com/typelevel/cats/blob/master/core/src/main/scala/cats/MonoidK.scala#L15
Pere Villega
@pvillega
Jul 27 2016 08:15
ok, I think I understand it. Thanks!
Cody Allen
@ceedubs
Jul 27 2016 12:04
@pvillega just to drive home the point that @mgttlinger is making: try to implement this method for the SemigroupK[Option] instance: def combine[A](x: Option[A], y: Option[A]): Option[A]. Since it has to work for all A, you don’t have access to a Semigroup[A]. Therefore you really only have a few possible implementattions
the implementation in Cats just returns the first one that is a Some (if there is one). There are a couple other possibilities.
which I leave as an exercise to the reader :)
Kai(luo) Wang
@kailuowang
Jul 27 2016 15:30
@ceedubs and @non I apologize that I merged #1234 without @non’s thumb up (he was mentioned), please let me know if there is any fix (revert or extra doc or whatever) needed.
Cody Allen
@ceedubs
Jul 27 2016 15:32
@kailuowang no worries. It seemed that several people agreed. We can always add it back if @non speaks up and we add some documentation/tests/etc
Ashic Mahtab
@ashic
Jul 27 2016 17:07

i'm looking into Validated, ValidatedNel, etc. Say I have the following two functions:

def getItems(id:String) : List[Item]
def getDetails(code:Int) : ItemDetail

where Item has a field called code. Any of the two can throw an exception. I'm looking for a way to fetch the items for an id, and then the details for those items, and accumulate all the errors. Validated sounds like a way to do this (though the first has to work for the following n queries to happen). I'm having trouble finding a nice way of doing this. Would appreciate any suggestions.

Cody Allen
@ceedubs
Jul 27 2016 17:09
@ashic if some of the items fail, do you still want a list of ItemDetail for the ones that succeeded?
Ashic Mahtab
@ashic
Jul 27 2016 17:09
yes
Cody Allen
@ceedubs
Jul 27 2016 17:10
okay let me throw something together
Ashic Mahtab
@ashic
Jul 27 2016 17:10
or no :) (looking at options)
ta
also you probably want to use either Xor.catchNonFatal or Validated.catchNonFatal
Travis Brown
@travisbrown
Jul 27 2016 19:28
Has there been any discussion of an 0.7.0 release? I'll have some time this weekend and there have been enough changes since 0.6 that I think it's time. I'd personally like to see #1225 and #1231 in 0.7, but otherwise I think things are in a reasonable state.
Cody Allen
@ceedubs
Jul 27 2016 19:31
@travisbrown there hasn’t really been any discussion that I’ve seen. I’ve been hoping for a 1.0 M1 around the end of August with hopefully a RC1 about a month later. I’m open to a 0.7 this weekend if an interim release would be useful
Travis Brown
@travisbrown
Jul 27 2016 19:36
@ceedubs wow, September for a 1.0 release candidate seems really early.
There are enough changes since 0.6 that I think a stable release before we start 1.0 milestones would be a good idea.
Cody Allen
@ceedubs
Jul 27 2016 19:38
@travisbrown yeah, that’s probably unrealistic given when I said the M1 would be. I just want to make sure we don’t put off a 1.0 release forever by being perfectionists
and I agree that a 0.7 in the very near future sounds like a good idea
Adelbert Chang
@adelbertc
Jul 27 2016 19:40
is 1.0 when we start doing the whole bincompat stuff
or may we start before that
Travis Brown
@travisbrown
Jul 27 2016 19:44
@ceedubs I'm thinking less of perfection and more of the rate that major changes are still happening—there are a ton of (valuable) breaking changes since 0.6 two months ago.
Cody Allen
@ceedubs
Jul 27 2016 19:44
@adelbertc well, we are already maintaining bin compat in the 0.6 series, but yeah 1.0 is when we will start putting off changes that aren’t binary compatible.
Adelbert Chang
@adelbertc
Jul 27 2016 19:45
oh are we already doing bincompat for the whole proj?
what sets 1.0 apart from 0.6 then if we're already maintaining bincompat
Cody Allen
@ceedubs
Jul 27 2016 19:46
@travisbrown yeah that’s true. Though I think a lot of those were things that we knew we planned to change for a long time and we we went to action on knowing that we are trying to get a 1.0 milestone out. But still, it does mean a lot of recent churn that should probably exist in the wild for longer before we consider things stable.
@adelbertc once we release 1.0 I’d like to slow the churn down. I don’t want people to need to update their (incompatible) cats dependency ever few months to keep up.
Adelbert Chang
@adelbertc
Jul 27 2016 19:48
ah so for example
1.0 and 1.1 wouldnt be super different
but may still be binary incompat
but it wouldnt involve something of the scale of say, the algebra => cats.kernel move
Cody Allen
@ceedubs
Jul 27 2016 19:49
I should add a couple disclaimers to everything I’m saying here:
1) I’m not any more in charge of releases than any other maintainer. I’ve just been interested in a release that I can feel comfortable recommending for usage in large projects.
2) I’ve never managed releases for a library used by lots of people (for some definition of lots), so I dont’ really know what I’m doing. I welcome recommendations and feedback.
@adelbertc right. And also I think the timeline between 1.0 and 1.1 would be considerably longer than that between 0.5 and 0.6 for example.
or at least binary-compatible changes would be backported to 1.0 for at least a year or something
Adelbert Chang
@adelbertc
Jul 27 2016 19:50
yeah same. the main thing holding us back here is binary compatibility i think and fear of huge sweeping changes
like you described
Cody Allen
@ceedubs
Jul 27 2016 19:52
@adelbertc there’s some discussion of version compatibility goals in #1233
Adelbert Chang
@adelbertc
Jul 27 2016 20:04
back to @travisbrown 's point, i do think 0.7 is due
i will review #1225 and #1231
Cody Allen
@ceedubs
Jul 27 2016 20:05
thanks @adelbertc and @travisbrown!
Adelbert Chang
@adelbertc
Jul 27 2016 21:08
@ceedubs merged #1231, looks like theres merge conflicts on #1225 but we got 2 :+1: s on that. prob also want to wait for @johnynek to approve as well
Cody Allen
@ceedubs
Jul 27 2016 21:09
@adelbertc okay thanks. I’ll resolve the conflicts this evening
Ashic Mahtab
@ashic
Jul 27 2016 23:00
@ceedubs thanks...separate from MonadCombine on Xors is what I needed. Any reason why Validated / ValidatedNel doesn't have a flatmap (and so can't be used in for comprehensions)?
Cody Allen
@ceedubs
Jul 27 2016 23:12
@ashic see the section titled "Of flatMaps and Xors" on http://typelevel.org/cats/tut/validated.html
Adelbert Chang
@adelbertc
Jul 27 2016 23:18
with its weird CSS styling
Cody Allen
@ceedubs
Jul 27 2016 23:20
yes :)