funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
mccraigmccraig 2017-11-22T09:26:27.000509Z

you might be looking for something like https://github.com/zalando-stups/cats.match @sinistral

sinistral 2017-11-22T10:03:06.000161Z

Thanks for the link @mccraigmccraig. I'll look into that and instaskip; hopefully that will give me a better idea of the patterns (no pun intended) that make sense.

mccraigmccraig 2017-11-22T10:07:09.000121Z

i haven't used cats.match myself @sinistral, so can't comment on how straightforward or effective it is - i have surprisingly little code which needs to process error states, so i've been ok with the more awkward branch style approach

sinistral 2017-11-22T10:17:49.000398Z

Is that an acceptable approach? Every time I use a branch-*, I can't help but feel that I should be using something like fmap instead. Between branch-* and with-context, I feel like I'm doing something wrong; I feel like I'm adding the kind of boilerplate that monads are monads are supposed to alleviate. (As I said ... very naïve questions, sorry)

mccraigmccraig 2017-11-22T10:32:15.000558Z

fmap won't do anything to errored values - that's the point of short-circuit evaulation

mccraigmccraig 2017-11-22T10:35:07.000051Z

a quick survey of my codebase - we've got 80kloc and 1000 uses of mlet - but only 20 branches - most of the branches are at component boundaries, doing things like formatting an http error response, so they aren't very common

mccraigmccraig 2017-11-22T10:35:31.000231Z

your use-case could be different of course, in which case i'd go for a pattern matching approach

sinistral 2017-11-22T11:14:15.000463Z

No, that reinforces my feeling that I'm doing something wrong, and that I'm resorting to branch when I shouldn't be. In most cases, I'd like short-circuit evaluation, but I'm using branch to package function return values correctly ... which probably means that I'm not using return as I should.

sinistral 2017-11-22T11:16:07.000227Z

I'll break my use-case down into a simpler example when I have a bit more time; that will give me something concrete to talk about (and hopefully help me to answer my questions on my own).

sinistral 2017-11-22T11:16:30.000263Z

Thanks for taking the time to respond @mccraigmccraig.