adam12 changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 2.7.2, 2.6.6, 3.0.0-preview2: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.org | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | BLM <3
bsdbandit-01 has joined #ruby
<panorain> CommunistWolf: Were you always good at math because I am not very good at math and I used to work on Metro Mobility Van's - Minneapolis St.Paul area of the U.S.A.
<CommunistWolf> I am definitely not good at maths
TCZ has joined #ruby
bsdbandit-01 has quit [Ping timeout: 265 seconds]
dfucci has joined #ruby
dfucci has quit [Ping timeout: 240 seconds]
ur5us has joined #ruby
Cork has joined #ruby
bsdbandit-01 has joined #ruby
postmodern has joined #ruby
Lewix_ has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
dfucci has joined #ruby
bsdbandit-01 has joined #ruby
dfucci has quit [Ping timeout: 264 seconds]
bsdbandit-01 has quit [Read error: Connection reset by peer]
* baweaver apparently moved in next to a maths professor
* baweaver will be using this for all it'
<baweaver> s worth
thecoffemaker has quit [Quit: So long and thanks for all the fish!]
prion has joined #ruby
e2 has quit [Ping timeout: 246 seconds]
thecoffemaker has joined #ruby
<panorain> Fair enough, I will be attentive
<apotheon> baweaver: cool
<baweaver> To be clear I'm horrid at math
<apotheon> baweaver: If the prof is cool, you should just have nerdy conversations.
<baweaver> Mostly cobbled together guesses from intuition
<baweaver> retired maths professor, so who knows.
<apotheon> I'm good at math, to the extent I have bothered to understand it, but I'm not deeply educated about it and I am bad at math *classes* because they're not really taught so much as dictated.
<apotheon> I have enjoyed three math-related courses.
<apotheon> One was in high school, two in college. I enjoyed the high school class because I used the extremely detailed syllabus to do everything I needed to ensure I got an A in the first week, then spent the rest of the semester reading sci fi.
<apotheon> I enjoyed the college classes because they were both taught by the same person -- probably the best teacher I have ever encountered.
<apotheon> One was a math class per se, and one (a symbolic logic course) counted as either math or philosophy depending on how one wanted it to appear in credits.
e2 has joined #ruby
evdubs has quit [Quit: Leaving]
evdubs has joined #ruby
prion has quit [Ping timeout: 256 seconds]
Technodrome has joined #ruby
oneeggeach has joined #ruby
braincrash has quit [Ping timeout: 260 seconds]
oneeggeach has quit [Quit: Leaving...]
dfucci has joined #ruby
prion has joined #ruby
dfucci has quit [Ping timeout: 240 seconds]
aremaref has quit [Ping timeout: 246 seconds]
bsdbandit-01 has joined #ruby
ruurd has quit [Quit: bye folks]
bsdbandit-01 has quit [Read error: Connection reset by peer]
lucasb has quit [Quit: Connection closed for inactivity]
TCZ has quit [Quit: https://github.com/srgx]
aremaref has joined #ruby
gix has quit [Ping timeout: 256 seconds]
prion has quit [Quit: WeeChat 2.8]
dfucci has joined #ruby
aremaref has quit [Ping timeout: 260 seconds]
ChmEarl has quit [Quit: Leaving]
dfucci has quit [Ping timeout: 256 seconds]
aremaref has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
aremaref has quit [Ping timeout: 246 seconds]
bsdbandit-01 has joined #ruby
aremaref has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
ule has quit [Ping timeout: 256 seconds]
Sou|cutter has joined #ruby
orbyt_ has joined #ruby
Sou|cutter has quit [Client Quit]
ule has joined #ruby
fippy has quit [Quit: Leaving]
aremaref_ has joined #ruby
aremaref has quit [Ping timeout: 246 seconds]
aremaref_ has quit [Ping timeout: 265 seconds]
aremaref has joined #ruby
aremaref has quit [Ping timeout: 240 seconds]
Iarfen has quit [Remote host closed the connection]
bukkitgerman8608 has quit [Quit: Du Mongo]
bukkitgerman8608 has joined #ruby
bukkitgerman8608 has quit [Client Quit]
bukkitgerman8608 has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
ian| has quit [Quit: Exiting]
panorain has quit [Quit: Leaving]
Rudd0 has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
adu has joined #ruby
dfucci has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dfucci has quit [Ping timeout: 240 seconds]
Swyper has quit [Remote host closed the connection]
elcuervo has joined #ruby
cuerbot has quit [Ping timeout: 240 seconds]
Swyper has joined #ruby
Swyper has quit [Ping timeout: 260 seconds]
freshmaker666 has quit [Remote host closed the connection]
freshmaker666 has joined #ruby
freshmaker666 has joined #ruby
duckpuppy has quit [Ping timeout: 256 seconds]
cloud69 has quit [Quit: Connection closed for inactivity]
duckpuppy has joined #ruby
Rudd0 has quit [Ping timeout: 246 seconds]
SeepingN has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
howdoi has quit [Quit: Connection closed for inactivity]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
leftylink has quit [Remote host closed the connection]
<KrzaQ> Does Hash have a method that would allow me to set a value for key and evaluate to the previous value for it? e.g. a = {foo: 1}; a.set(:foo, 2) == 1 # true
leftylink has joined #ruby
aremaref has joined #ruby
<havenwood> KrzaQ: Nope.
<KrzaQ> Ah, I hoped there was something added in newest ruby or maybe I misread the docs.
<KrzaQ> Thanks
<havenwood> KrzaQ: a[:foo].tap { a[:foo] = 2 }
<KrzaQ> I want to squeeze these three lines into one (advent of code spoilers) https://github.com/KrzaQ/AdventOfCode2020/blob/main/solutions/day15/main.rb#L6
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
blackmesa has joined #ruby
akem has quit [Ping timeout: 260 seconds]
<havenwood> KrzaQ: How about something like? https://gist.github.com/havenwood/5129252966aa7d1efdf682357eb61f45
<havenwood> KrzaQ: (untested)
<KrzaQ> ohhh, you can index each with index!
<havenwood> KrzaQ: #with_index, yes. #each_with_index, no. (oddly.)
<KrzaQ> oh, there's a dot...
<KrzaQ> welp, that's still great
<havenwood> KrzaQ: Or: File.read('data.txt').split(?,).to_h { [_1.to_i, _2.succ] }
<KrzaQ> huh, I don't need to specify the args and can use _1/_2 instead?
<KrzaQ> Or is it something specific to .to_h ?
<havenwood> KrzaQ: In general
<havenwood> KrzaQ: Ruby 2.7+
<KrzaQ> Cool!
<KrzaQ> Okay, your tap seems to work, when I tried it, it didn't, but I did .tap{ |v| mem[last] = turn; v || turn
envex has joined #ruby
jmcgnh has quit [Read error: Connection reset by peer]
<havenwood> KrzaQ: ahh
<havenwood> KrzaQ: You might consider moving `mem = MEM.dup` out to a kwarg even.
<havenwood> KrzaQ: def calc_xth x, mem: MEM.dup
<havenwood> KrzaQ: Makes it flexible and reads nicely.
<KrzaQ> I did that with default arguments in the past
<KrzaQ> though, does Hash preserve insertion order? I need DATA.last from my example
<havenwood> KrzaQ: Yeah, it does preserve order by key insertion.
<KrzaQ> buut, this was very enlightening already! I learned of _1/_2, tap and with_index
<havenwood> KrzaQ: But I might pull out that last to a constant too.
<havenwood> KrzaQ: And also pass it as a kwarg.
<KrzaQ> fair
<KrzaQ> hum, Hash doesn't seem to have a #last method
<havenwood> KrzaQ: Ah, yeah. You'd have to #reverse_each.first >.>
<KrzaQ> and it considers fresh insertions only for last, if I do hash.to_a.last, which wouldn't be okay for repeat numbers. I'll keep the two constants, I golfed a few days to the extreme, and while successful, I'd rather keep the code readable
jmcgnh has joined #ruby
<havenwood> KrzaQ: How about a bunch of constants :P
<havenwood> KrzaQ: If you #calc a bunch, constants might pay off in speed and memory.
<KrzaQ> I do it only twice (there are two parts for each task)
<KrzaQ> I gotta learn to #freeze
dfucci has joined #ruby
<KrzaQ> I'm fine leaving it as it is
adu has quit [Quit: adu]
dfucci has quit [Ping timeout: 256 seconds]
jinie has quit [Quit: ZNC 1.8.2 - https://znc.in]
jinie has joined #ruby
Rudd0 has joined #ruby
TomyWork has joined #ruby
Rudd0 has quit [Remote host closed the connection]
aremaref has quit [Ping timeout: 240 seconds]
naftilos76 has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
<naftilos76> Hi everyone, i want to get data from a ruby script while being in a rails controller. The ruby script will be caching data coming from a mqtt broker. I want the rails controller to get the data from the ruby script instead of the database because that would take much longer. One way to do it is through a file or a named pipe. However, if multiple users are connected then that file or pipe will be a limiting factor because it will be only one. I could
<naftilos76> create 10 or 20 pipes but i was wondering if there is another way. Can anybody suggest another approach?
dfucci has joined #ruby
akem has joined #ruby
dfucci has quit [Ping timeout: 240 seconds]
<havenwood> naftilos76: How about mount it as a little rack app?
<havenwood> naftilos76: mount LittleRubyScript, at: "some_route"
<havenwood> naftilos76: clearly time for gRPC :P
<naftilos76> havenwood: i have no idea what that means but i will have a look. I was also looking at the sysvmq gem which is a shared memory space between ruby processes.
<naftilos76> thanks
envex has quit []
jinie has quit [Quit: ZNC 1.8.2 - https://znc.in]
jinie has joined #ruby
vondruch has joined #ruby
blackmesa has quit [Ping timeout: 260 seconds]
queip has quit [Remote host closed the connection]
ur5us has joined #ruby
queip has joined #ruby
al2o3-cr has quit [Ping timeout: 256 seconds]
gavlee has quit [Ping timeout: 265 seconds]
hiroaki has joined #ruby
hiroaki has quit [Ping timeout: 264 seconds]
blackmesa has joined #ruby
banisterfiend has joined #ruby
blackmesa1 has joined #ruby
vondruch has quit [Ping timeout: 260 seconds]
blackmesa has quit [Ping timeout: 260 seconds]
<tempate> Is there a standardized way of finding the last occurrence of an element in a list?
nananalala has joined #ruby
<nananalala> hello
<nananalala> can sorbet understand access modifiers on attr_readers?
<nananalala> I want to write something like protected attr_reader :reader
postmodern has quit [Quit: Leaving]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
<leftylink> huh. if someone really really didn't like writing `tprev ? t - tprev : 0`, they could potentially write tprev &.-@&.+(t) || 0
<leftylink> I rarely see a stream of symbols that long
BenDover has joined #ruby
dfucci has joined #ruby
<nananalala> bye
nananalala has left #ruby [#ruby]
braincrash has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
<tempate> Hello. I'm trying to make a simple plot in Ruby. What gem should I use? I've been trying nyaplot but it doesn't seem to work.
ur5us has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vondruch has joined #ruby
<tempate> I managed to get a reduced version of my original plot to work on gnuplot
<tempate> I ran out of RAM when trying to run the whole thing
Rudd0 has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ta has quit [Quit: WeeChat 2.9]
ta has joined #ruby
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
banisterfiend has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
dfucci has quit [Ping timeout: 240 seconds]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
bvdw has quit [Quit: The Lounge - https://thelounge.chat]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
Fusl has quit [Max SendQ exceeded]
weaksauce has quit [Ping timeout: 272 seconds]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Fusl has joined #ruby
donofrio_ has joined #ruby
Fusl has quit [Max SendQ exceeded]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
al2o3-cr has joined #ruby
bijan_ has joined #ruby
silviu1 has quit [Remote host closed the connection]
somazero has joined #ruby
somazero has quit [Client Quit]
fanta1 has joined #ruby
bijan_ has quit []
TCZ has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
Fusl has joined #ruby
banisterfiend has joined #ruby
silviu has joined #ruby
Fusl has quit [Quit: K-Lined]
banisterfiend has quit [Ping timeout: 260 seconds]
banisterfiend has joined #ruby
banisterfiend has quit [Client Quit]
banisterfiend has joined #ruby
banisterfiend has quit [Remote host closed the connection]
dfucci has joined #ruby
Fusl has joined #ruby
bsdbandit-01 has joined #ruby
braincra- has joined #ruby
vondruch has quit [Ping timeout: 246 seconds]
braincrash has quit [Ping timeout: 256 seconds]
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
orbyt_ has joined #ruby
banisterfiend has joined #ruby
Technodrome has joined #ruby
TCZ has quit [Remote host closed the connection]
bsdbandit-01 has joined #ruby
banisterfiend_ has joined #ruby
banisterfiend has quit [Ping timeout: 260 seconds]
banisterfiend_ is now known as banisterfiend
<nakilon> 23:55:00 <nakilon> the easiest way that probably will work is 'spec.add_development_dependency "ruby-prof" unless ENV["CI"]'
<nakilon> of course I did a mistake -- forgot to pass the variable to docker in CI script
<nakilon> happens to me the 2nd time, I wonder when will be the 3rd one
<nakilon> 12:05:13 <tempate> Is there a standardized way of finding the last occurrence of an element in a list?
<nakilon> Array#rindex
<tempate> oh
<tempate> Thanks
<nakilon> about plots -- I don't usually render png in ruby; instead I make a wrapper on top of haml to render it in html with Chart.js but pretty sure there are simpler integrations of ruby with some js plotting libraries
akem has quit [Ping timeout: 265 seconds]
dionysus69 has joined #ruby
Swyper has joined #ruby
akem has joined #ruby
vondruch has joined #ruby
banisterfiend has quit [Quit: banisterfiend]
banisterfiend has joined #ruby
banisterfiend has quit [Ping timeout: 258 seconds]
banisterfiend has joined #ruby
dfucci has quit [Ping timeout: 264 seconds]
banisterfiend has quit [Ping timeout: 260 seconds]
adu has joined #ruby
banisterfiend has joined #ruby
banisterfiend has quit [Client Quit]
banisterfiend has joined #ruby
akem has quit [Quit: Leaving]
Mia has quit [Read error: Connection reset by peer]
Mia has joined #ruby
Mia has joined #ruby
^amra has joined #ruby
^amra has quit [Client Quit]
somazero has joined #ruby
Swyper has quit [Remote host closed the connection]
banisterfiend has quit [Read error: Connection reset by peer]
banisterfiend has joined #ruby
somazero has quit [Quit: Leaving]
banisterfiend has quit [Quit: banisterfiend]
banisterfiend has joined #ruby
ian| has joined #ruby
meimeix has quit [Ping timeout: 256 seconds]
BenDover has quit [Quit: BenDover]
Technodrome has quit [Ping timeout: 256 seconds]
DTZUZU has quit [Ping timeout: 265 seconds]
blackmesa has joined #ruby
kwilczynski has quit [Ping timeout: 260 seconds]
blackmesa1 has quit [Read error: Connection reset by peer]
nickb has quit [Ping timeout: 260 seconds]
DTZUZU has joined #ruby
nickb has joined #ruby
kwilczynski has joined #ruby
cd has quit [Quit: cd]
hiroaki has joined #ruby
<adam12> naftilos76: There's also Rinda from drb. Spin up a service that acts as a Rinda server and then you can have clients to it.
Rudd0 has quit [Ping timeout: 256 seconds]
Rudd0 has joined #ruby
duderonomy has joined #ruby
akem has joined #ruby
jinie has quit [Quit: ZNC 1.8.2 - https://znc.in]
jinie has joined #ruby
braincra- has quit [Read error: Connection reset by peer]
jinie has quit [Ping timeout: 240 seconds]
TCZ has joined #ruby
blackmesa has quit [Ping timeout: 272 seconds]
braincrash has joined #ruby
stryek has joined #ruby
ruurd has joined #ruby
Swyper has joined #ruby
ChmEarl has joined #ruby
Swyper has quit [Remote host closed the connection]
cuerbot has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
jinie has joined #ruby
elcuervo has quit [Ping timeout: 260 seconds]
TomyWork has quit [Remote host closed the connection]
braincrash has quit [Ping timeout: 240 seconds]
bsdbandit-01 has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
bsdbandit-01 has quit [Read error: Connection reset by peer]
adu has quit [Quit: adu]
somazero has joined #ruby
bsdbandit-01 has joined #ruby
adu has joined #ruby
TCZ has quit [Quit: https://github.com/srgx]
bsdbandit-01 has quit [Read error: Connection reset by peer]
somazero has quit [Quit: Leaving]
dionysus69 has quit [Ping timeout: 264 seconds]
elcontrastador has quit [Remote host closed the connection]
bsdbandit-01 has joined #ruby
aremaref has joined #ruby
Swyper has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
howdoi has joined #ruby
adu has quit [Quit: adu]
braincrash has joined #ruby
aremaref has quit [Ping timeout: 265 seconds]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
Swyper has quit [Ping timeout: 264 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
vondruch has quit [Read error: Connection reset by peer]
aremaref has joined #ruby
Technodrome has joined #ruby
Swyper has joined #ruby
Swyper has quit [Ping timeout: 264 seconds]
ellcs has joined #ruby
ellcs has quit [Ping timeout: 260 seconds]
prion has joined #ruby
donofrio_ has quit [Ping timeout: 246 seconds]
BTRE has quit [Remote host closed the connection]
bsdbandit-01 has joined #ruby
Swyper has joined #ruby
hiroaki has quit [Ping timeout: 272 seconds]
Swyper has quit [Ping timeout: 264 seconds]
blackmesa has joined #ruby
BTRE has joined #ruby
<prion> is anyone actually planning to use this type checker stuff in ruby 3
blackmesa1 has joined #ruby
<prion> seems to me that if you want a statically-typed language you wouldn't pick ruby in the first place
blackmesa has quit [Ping timeout: 260 seconds]
<havenwood> prion: Yes, we're already using RBS signatures with Steep at work.
<apotheon> I might.
<havenwood> prion: Sometimes you build something with Ruby and it gets wildly popular and suddenly adding types gets really appealing.
<havenwood> prion: Also, RBS signatures shipping with the stdlib makes really nifty text editor integrations possible without you even annotating your code with parallel sigs.
hiroaki has joined #ruby
<havenwood> prion: It's no loss if you don't want to add signatures but really nice wins for heavily-used codebases.
bsdbandit-01 has quit [Read error: Connection reset by peer]
<adam12> I'll be using it. Maybe not to 100% coverage inside apps, but definitely libraries and specific boundaries.
<prion> i guess i'm in the minority, i'm not a fan of typescript over javascript either
<adam12> prion: What language would you choose with static types and wasn't Ruby?
<prion> on paper i think Swift is pretty good, but i guess it depends what i
<prion> am building
<adam12> prion: I'd probably agree with you.
<prion> Nim and Crystal are probably the most ruby-esque but don't have great ecosystems
<prion> so maybe Go for web apps
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
Swyper has joined #ruby
bsdbandit-01 has joined #ruby
Mrbuck has joined #ruby
aremaref has quit [Ping timeout: 260 seconds]
bsdbandit-01 has quit [Read error: Connection reset by peer]
BananaDisco has joined #ruby
jinie has quit [Quit: ZNC 1.8.2 - https://znc.in]
jinie has joined #ruby
prion has quit [Ping timeout: 256 seconds]
aremaref has joined #ruby
dviola has joined #ruby
donofrio has joined #ruby
TomyWork has joined #ruby
* havenwood goes back to strapping a 1200cc motor on his bicycle
nofxx has joined #ruby
ramfjord has joined #ruby
<havenwood> adam12: https://assets.newatlas.com/dims4/default/6de064e/2147483647/strip/true/crop/599x399+56+0/resize/2400x1600!/format/webp/quality/90/?url=http%3A%2F%2Fnewatlas-brightspot.s3.amazonaws.com%2Farchive%2Frocket-bike.jpg
<havenwood> Oops, longer link url than I realized. >.>
<havenwood> I meant to shorten that.
<adam12> havenwood: I love it.
<nakilon> what's the point of the hype around dryrb?
<adam12> I've got a 1200cc engine powering an entire Volkswagen, so you putting one on a bike is .. fascinating.
dionysus69 has joined #ruby
<adam12> nakilon: Any specific library? Their ecosystem is fairly large.
<nakilon> I've read some intro article about monads -- it's something about type safety, and looks like a huge overhead
<nakilon> adam12, in every vacancy now they say "dry rb"
<baweaver> The idea behind most of DryRB, if not FP in general, is to be explicit about data flow
rippa has joined #ruby
<nakilon> people can make such a mess in codebase even without libraries, I imagine what do they do with them
<havenwood> nakilon: Folk were making functional-style apps and found common abstractions helpful.
<baweaver> Instead of using exceptions they used values.
<apotheon> That's a scary bicycle.
<adam12> nakilon: If anything, I find it cleans up codebases
<baweaver> and because they have to explicitly deal with those values you have to deal with exceptional data as it happens instead of letting it off
<adam12> But again, it _depends_ on which libraries. I haven't used all of them so I can't make a blanket statement.
<baweaver> My personal belief is that exceptions should only be for truly exceptional behavior. DryRB and monadic design takes that to an extreme and gets rid of them almost entirely.
<baweaver> Consider a `select` method which selects elements that match a condition in an array
<baweaver> What if it raised an exception if it found nothing?
<baweaver> Would that make much sense?
<baweaver> Instead of doing that, we return an empty array
<baweaver> and because of that we don't have to have some intermediary catch for every failure. We can assume sane defaults that we can chain off of. If nothing was selected it won't hit any further chained methods
<nakilon> let's see: 1. Ruby (Rails/Roda/Sinatra), Dry.rb, RSpec, ... 2. Ruby 2.6, Dry-rb, RSpec,... 3. ruby ror device pundis dry-rb. .. 4. ruby dry-rb rom-rb ...
<baweaver> so you can: array.select(&:even?).map { |v| v * 2 }.sum
<nakilon> maybe 1 and 2 are the same place from different HR agencies
<nakilon> I don't get it about exceptions -- if you wrap something in handlers that work like rescue, it does not fix the code itself
<nakilon> you just write some handler that probably will never even happen to work
<baweaver> Monadic design is entirely based around sane return values allowing you to chain transformations.
<baweaver> Let's start with a simpler case
<baweaver> Say we have numbers, like { 1 2 3 4 5 }
<baweaver> The set of numbers there has some fun properties to it
<nakilon> 22:57:20 <baweaver> Instead of doing that, we return an empty array
<nakilon> if something goes not as planned the program should halt the execution
<nakilon> that's called a defense programming
<baweaver> They can be combined with `+` and get back another number
<nakilon> bugs should be loud and stop things
<baweaver> Bugs should, yes, but what qualifies as a bug?
<baweaver> Turns out very few things, and they should be explicitly handled as such
<baweaver> Numbers also have a value which you can add to any number and get back that number, `0`
<baweaver> so 1 + 0 = 1
<baweaver> They can also be grouped as long as they retain the same order. `1 + 2 + 3 == 1 + (2 + 3) == (1 + 2) + 3`
<baweaver> Those represent properties of closure (`+`, or `join`), identity (`0` or `empty`), and distributive
<baweaver> Arrays work the same way with `+` and `[]` as empty
<baweaver> Strings with `+` and `""`
<baweaver> this pattern starts being repeated
<baweaver> Given that you can keep applying transformations to them. If one of those steps raised an exception instead of a sane default, or rather a known "empty" value, it would break that chain
<leftylink> hmm? why is this the first time I'm hearing of dryrb... how long has it been around
<baweaver> Enumerable in Ruby follows this pattern in a lot of ways
<nakilon> when you get a task to make a feature from your manager and you are supposed to sum these numbers, if obtaining some number raises the unexpected error, manager should know it -- instead we write some code that converts the exception to 0 and we add 0 pretending it was ok
DarthGandalf has quit [Remote host closed the connection]
<leftylink> since 2016 I guess
<baweaver> When would it though?
DarthGandalf has joined #ruby
<baweaver> This is a common design pattern in Erlang or MapReduce
<nakilon> baweaver you don't know, you have to have this bug to show itself, stop some process execution and refuse to continue until you figure out the problem and make a proper fix
<baweaver> Batch out data that follows those three rules, assign them IDs, merge them as they come back in. If no results came in, use an empty value instead.
<baweaver> The point is not to swallow exceptions, but to ensure exceptions are truly exceptional
<baweaver> What do you think `rescue` is doing?
<baweaver> It's rescuing from known errors and handling them, otherwise allowing it to break up the chain.
<leftylink> I guess I'd be OK with using dry-struct...
<nakilon> " If no results came in, use an empty value instead." -- that's some assumption taken from nowhere, why do you think those who design product features want this to be like that?
<baweaver> applying that thinking, however, to trying to understand monadic design is being pretty pedantic for the sake of it.
<havenwood> leftylink: a bit simpler variant of that was proposed for Ruby 3 and didn't quite make it but Matz wasn't entirely opposed
<havenwood> leftylink: maybe Ruby 3.1?
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<leftylink> hmm
<nakilon> also I imagine this will have a bunch of exception handlers duplicating each other on different levels
<nakilon> excessive unneded code
ur5us has joined #ruby
<baweaver> The problem is you're stuck on one way of thinking and not really allowing yourself to explore the other.
<baweaver> Of course there are exceptions and errors, but that's not the point of this mental exercise.
<nakilon> I've explored enough the python code practice to put try except pass into every 10 lines of code
<adam12> havenwood: Maybe they could stop including Enumerable in Struct... :)
<havenwood> adam12: Matz liked Struct::Value and Struct::Basic not including Enumerable.
<adam12> havenwood: Oooh. That makes me happy
<havenwood> adam12: But Struct::Tuple and normal Struct would.
<adam12> I use a _ton_ of dry-struct. Basically anywhere I want a ridgid boundary.
<havenwood> Matz hasn't approved it, but that was where it left off as his top choice.
<havenwood> I guess we could implement those interfaces easily enough as a library. Nice to have it be "real" though. :)
<adam12> nakilon: I use monads frequently for anything that I don't control. Talking to Stripe? It returns a monad. I don't rescue everything, just ones I know that I can handle.
SeepingN has joined #ruby
dionysus69 has quit [Ping timeout: 272 seconds]
<nakilon> adam12 what does it give? if you wanted to get some data from external service and you didn't get it, you can't proceed anyway; whether you use these things or not, you'll have to tell user "something went wrong", right?
<adam12> nakilon: Sure, but where do I rescue `Stripe::CardError`?
<adam12> nakilon: Is `Stripe::CardError` a construct of my app? Should my app be concerned about it? Maybe. But in how many places? Or do I wrap it with my own exception?
<nakilon> catch Stripe Error in the top call of it
gix has joined #ruby
<nakilon> I mean Stripe::Error, such parent classes are usual for gem providers
<adam12> nakilon: In my controller/route? Do you move it to an adapter? This is where a monad helps.
<adam12> What if I'm moving from Stripe to Square? Replace every instance of Stripe::CardError with Square::HavenwoodBrokeIt?
<havenwood> I'd just like to say that everyone who blames me for that error is wrong.
<havenwood> Look past the name.
TomyWork has quit [Remote host closed the connection]
<nakilon> I'm not into web and MVC, sorry, these words tell nothing to me
<adam12> havenwood: I need to spend more time with the Square SDK apparently.
<havenwood> adam12: For anything CRUDish I'm tempted to think Active Model might be best.
<havenwood> I'm impressed by its modularity.
<adam12> havenwood: I dont' have Active anything in my apps .. :)
<havenwood> adam12: Ah, good point! Hah.
<havenwood> Sequel. <3
<havenwood> adam12: I like backing Active Model with an API way more than I expected.
bsdbandit-01 has joined #ruby
<havenwood> Nifty you can back Active Model with a text file or whatever you want and with attributes API you wouldn't know it wasn't Active Record if you just add the same niceties.
<havenwood> Granted, it's a fair amount of effort to get all the Active Record niceties, but for something heavily used it seems worthwhile.
<adam12> havenwood: Nice. I'm trying to find more time to work with ROM
<havenwood> I need to make more examples since I don't know of many. https://github.com/havenwood/example/blob/master/app/models/customer.rb
<adam12> havenwood: Sequel makes me happy but I think ROM would be gravy on the top.
<havenwood> Neat to not know if it's a DB or an API under the hood.
<havenwood> adam12: I'm tempted by ROM but every time I dabble I back off for whatever reason.
bsdbandit-01 has quit [Read error: Connection reset by peer]
<havenwood> It'd be kinda fun to do a tactile Active Model with a Pi or something along those lines.
<havenwood> Just needs to CRUD in some form.
<havenwood> nakilon: How I like to wrap an API in Rails, FWIW https://youtu.be/6h5TbKBnLws?t=75
Mrbuck has quit [Quit: WeeChat 2.9]
hiroaki has quit [Ping timeout: 246 seconds]
hiroaki has joined #ruby
hiroaki has quit [Max SendQ exceeded]
DarthGandalf has quit [Remote host closed the connection]
DarthGandalf has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
hiroaki has joined #ruby
<nakilon> I'm not touching Rails even with a 5 meters long stick
al2o3-cr has quit [Ping timeout: 256 seconds]
hiroaki has quit [Ping timeout: 272 seconds]
ramfjord has quit [Ping timeout: 272 seconds]
al2o3-cr has joined #ruby
<havenwood> nakilon: COVID distancing?
<apotheon> That's supposed to be two meters.
<havenwood> I touch Rails without even wearing gloves. Just wear a mask.
<apotheon> har
<havenwood> apotheon: An extra meter seems prudent.
<apotheon> Three extra meters might be excessive.
<havenwood> apotheon: Safe from an off-by-one error.
<apotheon> "Yeah, um, I have to cross the street now."
<havenwood> apotheon: Medical programming.
<apotheon> (gets hit by a car)
<apotheon> SAFE FROM INFECTION
hiroaki has joined #ruby
ramfjord has joined #ruby
banisterfiend has quit [Quit: banisterfiend]
shokohsc has quit [Quit: The Lounge - https://thelounge.chat]
shokohsc has joined #ruby
naftilos76 has quit [Ping timeout: 240 seconds]
hiroaki has quit [Ping timeout: 264 seconds]
prion has joined #ruby
weaksauce has joined #ruby
hiroaki has joined #ruby
Guest42485 has joined #ruby
Guest42485 has quit [Read error: Connection reset by peer]
iam_ has joined #ruby
troll_ has joined #ruby
iam_ has quit [Client Quit]
<troll_> hi.
TCZ has joined #ruby
ramfjord has quit [Ping timeout: 256 seconds]
ian| has quit [Quit: Exiting]
ramfjord has joined #ruby
prion has quit [Quit: WeeChat 2.8]
fanta1 has quit [Quit: fanta1]
troll_ has quit [Quit: Leaving]
cd has joined #ruby
bsdbandit-01 has joined #ruby
dionysus69 has joined #ruby
blackmesa has joined #ruby
blackmesa1 has quit [Ping timeout: 260 seconds]
TCZ has quit [Quit: Wawel - Czujesz sie dobrze, czynisz dobrze]
chromis has joined #ruby
hiroaki has quit [Ping timeout: 256 seconds]
<phaul> &renick
rubydoc__ is now known as rubydoc
<rubydoc> okay
<phaul> :)
prion has joined #ruby
tempate has left #ruby [#ruby]
bsdbandit-01 has quit [Read error: Connection reset by peer]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hiroaki has joined #ruby
blackmesa has quit [Ping timeout: 260 seconds]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
Swyper has quit [Remote host closed the connection]
TCZ has joined #ruby
powerhouse has quit [Read error: Connection reset by peer]
dionysus69 has quit [Ping timeout: 268 seconds]
powerhouse has joined #ruby
ian| has joined #ruby
prion has quit [Ping timeout: 246 seconds]
ule has quit [Changing host]
ule has joined #ruby
prion has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
Lyubo1 has quit [Ping timeout: 256 seconds]
BananaDisco has quit [Quit: Leaving]
hiroaki has quit [Ping timeout: 240 seconds]
ur5us has quit [Ping timeout: 258 seconds]
hiroaki has joined #ruby
powerhouse has quit [Remote host closed the connection]
Technodrome has joined #ruby
akem has quit [Quit: Leaving]
powerhouse has joined #ruby
Lyubo1 has joined #ruby
Swyper has joined #ruby