rubyaustralia / roro

The Ruby on Rails Oceania (RORO) Sydney meetup
https://www.github.com/rails-oceania
177 stars 15 forks source link

Intro to dry-monads #178

Closed paulfioravanti closed 6 years ago

paulfioravanti commented 6 years ago

dry-monads has released version 1.0, so this is a presentation request for someone to talk about it, and monads in general.

Things that could be covered are:

I'd wager that, given that the content of the presentation would involve monads, it would be an intermediate-level and up presentation, but you'd be a total hero if you can do a explain-it-like-I'm-five-years-old description of monads to make it accessible for everyone.

paradisaeidae commented 6 years ago

OK, I am interested in hearing this one. I do often talk to myself. So I guess it figures I talk about it?

paulfioravanti commented 6 years ago

Thanks for volunteering to take this talk on, @paradisaeidae! Which meetup would you like to aim for? August has spots available for a full length talk, and September has spots available for a full-length or lightning talk.

paradisaeidae commented 6 years ago

Pencil me in for September for now. I have some thing-dings to do for prep on it. Schedule unknown.

paulfioravanti commented 6 years ago

Full length or lightning talk for September?

paulfioravanti commented 6 years ago

This may be useful for the "what is a monad" question: https://www.quora.com/How-would-you-explain-Monads-in-functional-programming-to-a-child

filterfish commented 6 years ago

@paulfioravanti I'm not sure you would be able to do the subject justice in a lightening talk.

paradisaeidae commented 6 years ago

Hi Richard, Agreed. Penciled as a full length talk. In emailed reply to Paul. Did not reach this thread. I met with Tim on Tuesday. It was good to have an analog yak. Happened to be in Canberra.

paulfioravanti commented 6 years ago

I don't seem to have received this emailed reply, but regardless, given the comment above, @paradisaeidae, I'll lock you in for a full-length September talk on this.

paulfioravanti commented 6 years ago

@paradisaeidae Just keep in mind when preparing the talk that it's likely that not many in the audience will know what a monad is, or much about functional programming. So, see if you can aim the talk as beginner as possible (given the subject matter) and keep it as much as possible within the context of Ruby. That would be great! 👍 If you need anyone to dry-run the talk with, let @RocketRobC or myself know!

paulfioravanti commented 6 years ago

@paradisaeidae Mark, for the RORO run sheet, what is your surname, and do you have a Twitter account?

paradisaeidae commented 6 years ago

Surname is Turner. Twitter is @paradisaeidae Is there sound on that very big tellyVision?

paulfioravanti commented 6 years ago

Thanks. If you connect via HDMI, I think there would be. What is it that you are planning?

filterfish commented 6 years ago

@paulfioravanti this is the article that really me understand: http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html

EDIT: In case you were wondering why I've just posted the above comment it's because I've only just noticed the Quora link you posted some time ago. Context and all that!

RocketRobC commented 6 years ago

@filterfish What a great article!

paradisaeidae commented 6 years ago

TLDR; niftierideology‏ @niftierideology "Everything is composed of Functads which are themselves a Tormund of Gurmoids, usually defined over the Devons. All you have to do is stick one Devon inside a Tormund and it yields Reverse Functads (Actually Functoids) you use to generate Unbound Gurmoids."

"As for understanding monads, don't worry too much about it. Read about them what you find interesting and don't worry if you don't understand right away. Monads are one of these things where understanding trickles into your brain by practice, one day you just suddenly realize you understand them."

David K. Hess "Monads in typical usage are the functional equivalent of procedural programming's exception handling mechanisms. In modern procedural languages, you put an exception handler around a sequence of statements, any of which may throw an exception. If any of the statements throws an exception, normal execution of the sequence of statements halts and transfers to an exception handler. Functional programming languages, however, philosophically avoid exception handling features due to the "goto" like nature of them. The functional programming perspective is that functions should not have "side-effects" like exceptions that disrupt program flow. In reality, side-effects cannot be ruled out in the real world due primarily to I/O. Monads in functional programming are used to handle this by taking a set of chained function calls (any of which might produce an unexpected result) and turning any unexpected result into encapsulated data that can still flow safely through the remaining function calls. The flow of control is preserved but the unexpected event is safely encapsulated and handled."

jes5199 "And in the simple case, when you use a monad, it feels the same -- you define a list of expressions that happen in order. Except that, depending on which monad you use, your code might run in order (like in IO monad), in parallel over several items at once (like in the List monad), it might halt partway through (like in the Maybe monad), it might pause partway through to be resumed later (like in a Resumption monad), it might rewind and start from the beginning (like in a Transaction monad), or it might rewind partway to try other options (like in a Logic monad). And because monads are polymorphic, it's possible to run the same code in different monads, depending on your needs."

Diagrams: http://www.matusiak.eu/numerodix/blog/2012/3/11/monads-for-the-layman/ https://discourse.dry-rb.org/t/proper-usage-of-dry-transaction-with-dry-validation/594 https://opencollective.com/rom?referral=18247

Links: https://dry-rb.org/gems/dry-monads/1.0/ http://dry-rb.org/gems/dry-transaction/ https://importantshock.wordpress.com/2009/01/18/jquery-is-a-monad/ https://stackoverflow.com/questions/11871065/monads-in-javascript http://hanamirb.org/guides/1.2/getting-started/ Tom Stuart - Refactoring Ruby with Monads: https://www.youtube.com/watch?v=J1jYlPtkrqQ https://github.com/tomstuart/monads https://www.slideshare.net/RubyMeditation/monads-in-ruby-victor-zagorodny Railway oriented programming: Error handling in functional languages by Scott Wlaschin: https://vimeo.com/113707214

Igor Morozov - Ducks and monads: wonders of Ruby types: https://www.youtube.com/watch?v=v-H9nK8hqfE

Chats, forums: https://gitter.im/dry-rb/chat https://gitter.im/hanami/chat https://discourse.rom-rb.org/latest

RocketRobC commented 6 years ago

Hi @paradisaeidae,

Everything OK for tonight? I did notice you asked about the sound from the TV, was there something you needed to playback?

filterfish commented 6 years ago

@RocketRobC yeah it really is a good article. I found that alternating between the Typeclassopedia (which is specific to Haskell) and the Adit article really helped cement things for me.

I've been thinking about this a fair over the weekend and it occurred to me that monoids, monads, applicatives, arrows, functors, etc, etc are really just like the GOF design patterns in that they are useful abstractions that developers can use to help solve problems. The only real difference is that the functional "design patterns" are mathematically rigorous. And have terrifying names!

paradisaeidae commented 6 years ago

Thanks for the positive comments. Much appreciate! There is new ground here for me. IANExpert. Ezspecially in that the dry-monad is but one of a number of gems on the dry-rb toolbox. So it is not a framework. It is a collection of tools. Which can be deployed for specific purpose or collective wholeness. https://dry-rb.org/ The materiel is a study, longer than 15 minutes. Ping me @paradisaeidae for the preso web-app. It is in prototype state. Links will be extracted to here soon.

paulfioravanti commented 6 years ago

Hey Mark, thanks for your talk (even though I didn't get to see it)! When you have a few moments, could you please export your slides to PDF and put them up on the slide-sharing platform of your choice (Slideshare, SpeakerDeck etc) and: