Category Theory for Programmers: Chapter 4 - Kleisli Categories

  Рет қаралды 9,043

code_report

code_report

Күн бұрын

PL Virtual Meetup: www.meetup.com...
CtFP Textbook: github.com/hme...
Github Repo: github.com/cod...
PLVM Discord: / discord
PLVM Twitter: / plvirtualmeetup
Follow me on Github: github.com/cod...
Follow me on Twitter: / code_report
Follow me on LinkedIn: / codereport

Пікірлер: 14
@henrykkaufman1488
@henrykkaufman1488 2 жыл бұрын
Love the Princess Bride intro, Bartosz really looks like Inigo Montoya!
@StewartMcGinnis
@StewartMcGinnis 3 жыл бұрын
Even though I've tried reading it in lots of places before, you're walking through the writer category was the first time I really understood it as being "monad-y" and why "monad-y-ness" is useful for programming and not just a coincidental math structure academics managed to fit over programing patterns. Thanks! (For context, I'm a mathematician by schooling and was taught to code in primarily imperative and object oriented style)
@MCLooyverse
@MCLooyverse 2 жыл бұрын
@14:00, you have functions wrapped in lambdas, but function pointers exist. You should be able to just write `safe_reciprocal` and `safe_root`. If that were necessary, that would be a good time for a macro like #define LAMBDAWRAP(f) [](auto x){ return f(x); }
@RogasTV
@RogasTV 3 жыл бұрын
14:08, I would try „return compose(&safe_reciprocal, &safe_root)(n);”. It should be possible as long as lambdas do not capture anything. I enjoyed this episode. Thanks!
@Adowrath
@Adowrath 2 жыл бұрын
Yeah, it works by just passing the functions without explicitly taking their address too, I don't know why he talked about them not being first-class like that.
@theondono
@theondono Жыл бұрын
Chapter 4 and I’ve already had to rewatch the Princesa Bride
@felipenascimento6118
@felipenascimento6118 Жыл бұрын
I'm finding APL to be a very confusing language. I think that using many operators like that creates a scenario where the language requires training to be readable, which for me is undesirable. A good thing of using keywords instead is that one can take a very good guess of what's going on, even if they don't know the language
@RobotProctor
@RobotProctor 2 жыл бұрын
Me after watching this video: oh, so a Kleisli category is like a composition of categories together. Wikipedia: a Kleisli category is a category naturally associated to any monad T. It is equivalent to the category of free T-algebras Me: wtf? I'm now questioning everything I just learned.
@NikolajLepka
@NikolajLepka 2 жыл бұрын
My fave way of doing roots in APL is actually like this (in J notation to avoid unicode): y^%2, or "right arg raised to the reciprocal of 2". It's one fewer symbol, but idk if it's any less fast
@retagainez
@retagainez 7 ай бұрын
2:12 The remark on difficulty of unit testing the negate function here is not correct. You don't have to test what a string is when you're unit testing. You would instead test that there is an existence of a string and you can avoid everything except what the function is meant to add. You would instead just unit test some decorator and that it works for any function (which is in a way composing logging with a function). Typically, unit testing should not involve testing the set of all possible values by forcing your implementation to focus on those values (rather you focus on common behaviors), and even less so when dealing with a library (in this case the string data type). What you meant to mention (when you started talking about all combinations of string prefixes concatenated with the hardcoded value) is that is it very difficult to use memoization, as Bartosz states in the lecture, which is different and speaks on performance improvements for repeated iterations that are slow. The same unit testing exists in the purer form of the same function, it's just the unit testing would focus instead on composing strings (which is what you would anyway in the original side-effect function definition.) Even then, regardless of unit testing, integration tests would be useful here, on the logger, to prove that it produces logs for all of your behaviors.
@tonaxysam
@tonaxysam 2 жыл бұрын
my name is inigo montoya... you killed my _functor_ prepare to die
@foxoninetails_
@foxoninetails_ 3 жыл бұрын
17:14 I'm very, very new to APL (just started playing around with it in the past couple of days), but I did manage to find a relatively clean way to compose functions around your method of optional types, by defining safe_compose as a dyadic operator. It also avoids inner assignment by nesting definitions. Is this something that should be avoided for a reason I'm missing, or just something that didn't come to mind? safe_compose ← {⍵⍵ {has_value ⍵: ⍺⍺ value ⍵ ⋄ nullopt} ⍺⍺ ⍵} Or without predefining has_value and value for the sake of conciseness: safe_compose ← {⍵⍵ {⊃⍵:⍺⍺⊃⌽⍵ ⋄ nullopt} ⍺⍺ ⍵} After which it can be used as such: safe_root_reciprocal ← safe_reciprocal safe_compose safe_root
Category Theory for Programmers: Chapter 1 - Category
20:14
code_report
Рет қаралды 62 М.
Players vs Corner Flags 🤯
00:28
LE FOOT EN VIDÉO
Рет қаралды 63 МЛН
БЕЛКА СЬЕЛА КОТЕНКА?#cat
00:13
Лайки Like
Рет қаралды 1,6 МЛН
Cute
00:16
Oyuncak Avı
Рет қаралды 12 МЛН
Category Theory 3.2: Kleisli category
41:58
Bartosz Milewski
Рет қаралды 67 М.
What is a Monad? - Computerphile
21:50
Computerphile
Рет қаралды 603 М.
Haskell for Imperative Programmers #37 - Arrows
13:15
Philipp Hagenlocher
Рет қаралды 11 М.
Kleisli categories
7:04
Fredrik Nordvall Forsberg
Рет қаралды 317
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 809 М.
"Categories for the Working Hacker" by Philip Wadler
41:40
Strange Loop Conference
Рет қаралды 65 М.