Presto posted:You already lost me. They mean a type like the List in List<T> or the Optional in Optional<T>.
|
|
# ? Jun 19, 2019 22:23 |
|
|
# ? May 17, 2024 15:48 |
|
sunaurus posted:Nobody can beat this guy https://www.linkedin.com/in/jonschlinkert/ His linkedin profile is the best. president and founder of so many things, gives talks about entrepreneurship, and also somehow the #1 maintainer of npm with over 400 modules. Watch out Elon Musk!
|
# ? Jun 19, 2019 22:33 |
|
Carbon dioxide posted:I mean, I do some functional programming and I'm not a theory nerd, and as a result monads are simple for me. They're literally a box you can put things of any type in and there's a way to change what's in the box without changing the box itself. That's all (and everything >95% of functional programmers ever need to know about them). i'm still wondering what box metaphor we're using here and how it compares to procedural mutable boxes that humans have interacted with
|
# ? Jun 19, 2019 22:45 |
|
JawnV6 posted:i'm still wondering what box metaphor we're using here and how it compares to procedural mutable boxes that humans have interacted with After a box's contents have been emptied, it can be repurposed for a space ship
|
# ? Jun 19, 2019 23:52 |
|
poemdexter posted:https://www.linkedin.com/in/jonschlinkert/ His 'ansi-cyan' library is used in 223,321 other repositories. It's enough to make me quit programming.
|
# ? Jun 20, 2019 00:55 |
|
Nolgthorn posted:His 'ansi-cyan' library is used in 223,321 other repositories. It's enough to make me quit programming. How many of those libraries is he an owner or contributor to? I dunno that I believe that stat by the way.
|
# ? Jun 20, 2019 01:01 |
|
I believe it, his stuff is like an infestation. He has myriad atom-sized modules, which are used in slightly less utterly useless modules, which get used in slightly useful modules, which get used in middlingly important webpack plugins, and suddenly a single line of code which checks whether a string has a space in it is being used by NASA to serve one of NASA's less important websites and "my code is used by NASA every day, don't forget to watch and star!"
|
# ? Jun 20, 2019 01:15 |
|
Nolgthorn posted:His 'ansi-cyan' library is used in 223,321 other repositories. It's enough to make me quit programming. Maybe it should just be enough to make you quit programming JS
|
# ? Jun 20, 2019 01:30 |
|
Or stop importing packages to do built-in language capabilities
|
# ? Jun 20, 2019 02:07 |
|
The problem is the garbage is a transitive dependency pulled in by actually useful packages. Those actually-useful packages shouldn’t be pulling them and should be actively minimizing their dependency chains but at some point developers decided that pulling in a library for every trivial case was frictionless and meant you were a good and smart.
|
# ? Jun 20, 2019 02:11 |
|
Burritos
|
# ? Jun 20, 2019 02:13 |
|
The only law of monads is that if somebody mentions the word then 10 others must appear to explain them, all slightly differently
|
# ? Jun 20, 2019 02:54 |
|
I had heard of functors when I worked at a place that did C programming. Until this page I thought they were just a shortened way of saying "function pointers". I know what those are, but not functors, apparently. I don't know what "monads" are but I'm guessing they do not show up in JavaScript because I don't hear about them around what I do now.
|
# ? Jun 20, 2019 02:57 |
|
ryde posted:The problem is the garbage is a transitive dependency pulled in by actually useful packages. I think what usually happens is the author of one of the garbo-utils sends a pull request to an actually useful library to make it use their piece of poo poo one-liner utility, and the maintainer of the useful library doesn't really have time to look into it so just approves it.
|
# ? Jun 20, 2019 02:57 |
|
Ah gently caress that is so malicious, and explains a lot about npm
|
# ? Jun 20, 2019 02:57 |
|
Dumb Lowtax posted:I had heard of functors when I worked at a place that did C programming. Until this page I thought they were just a shortened way of saying "function pointers". I know what those are, but not functors, apparently. I don't know what "monads" are but I'm guessing they do not show up in JavaScript because I don't hear about them around what I do now. Monads are everywhere. Arrays are monads, for instance. It's just only in academic languages are they called monads.
|
# ? Jun 20, 2019 03:05 |
|
Oh son of a bitch, I had never noticed the flat() method in the JS Array spec. Thank you!
|
# ? Jun 20, 2019 03:45 |
|
arrays are not monads array is a monad
|
# ? Jun 20, 2019 04:13 |
|
Elegant error handling with the JavaScript Either Monad This is a good introduction because it doesn't spend a lot of time explaining what monads are in general, and it shows you how to use one to solve a real problem. The error handling methods that you get out of functional programming are good and people should be paying attention to them.
|
# ? Jun 20, 2019 04:47 |
|
So std::list<T> would be a monad, but types like std::map<K, T> would not?
|
# ? Jun 20, 2019 04:52 |
|
zergstain posted:So std::list<T> would be a monad, but types like std::map<K, T> would not? edited post after research: It is in Scala, but not in Haskell. It's possible to implement it yourself, but it depends on the semantics you want it to have. xtal fucked around with this message at 05:26 on Jun 20, 2019 |
# ? Jun 20, 2019 05:01 |
xtal posted:edited post after research: It is in Scala, but not in Haskell. It's possible to implement it yourself, but it depends on the semantics you want it to have. That's interesting, what are the differences in semantics that make it possible in Scala?
|
|
# ? Jun 20, 2019 05:34 |
|
VikingofRock posted:That's interesting, what are the differences in semantics that make it possible in Scala? The map() function on a Map in scala expects a function from (K, V), that is a tuple, to a new (key, value) tuple. I hardly ever need this because there's a convenience mapValues() function available that leaves the keys as they are. I don't know from the top of my head what happens if map() generates a duplicate key. Flatmap works similarly btw. There's even a special notation available for these map entries-as-tuples: (key -> value) Carbon dioxide fucked around with this message at 05:59 on Jun 20, 2019 |
# ? Jun 20, 2019 05:41 |
|
zergstain posted:So std::list<T> would be a monad, but types like std::map<K, T> would not? There are two answers, depending on what you were getting at: 1) This is where the ad-hoc notation of conventional languages become a problem. The type std::map<K, T> would in Haskell be written as 'Map k t', which cannot be a monad. The partially applied type 'Map k' could be, though. In Haskell, a monad instance is defined for a type constructor (a type of kind '* -> *'), not a fully applied type. This is less natural to talk about with a C++-ish notation for parametric polymorphism. You can write 'std::map<K>', but I don't think the compiler will accept it. 2) You cannot define a monad for something like std::map<K, T> specifically, since the 'return' method is only called with a T. You'd have to conjure up a K out of nowhere.
|
# ? Jun 20, 2019 06:33 |
|
Dumb Lowtax posted:I had heard of functors when I worked at a place that did C programming. Until this page I thought they were just a shortened way of saying "function pointers". I know what those are, but not functors, apparently. Nah, that's just, C++ people use functor to mean anything that can be called like a function, so also function pointers and objects that define operator(), whereas haskell people use functor to mean something utterly unrelated.
|
# ? Jun 20, 2019 08:35 |
|
Carbon dioxide posted:Wow the coding horror is in the thread. While technically correct this is the kind of long winded stuff that chases good devs away from functional programming. And there's absolutely no need for an explanation like this. ... ... or there are multiple ways to explain concepts like "monad", some of which will work for some people and not others? What you're essentially saying here is: if you don't think like me (in particular, if you didn't find the explanation to be unhelpful like I did) then you aren't really a programmer. And the only appropriate response to that is to tell you to gently caress off. VikingOfRock's explanation was the kind of concept-explanation I am used to reading, as someone who was a failed mathematician in a previous life. It makes sense while not necessarily being the kind of explanation that would be helpful for every possible reader.
|
# ? Jun 20, 2019 09:58 |
|
But then you could have gotten an equivalent mathematical introduction to monads via one of the hundred million other monad tutorials on the internet. It's ok though, because we need to account for the Zeroth Monad Law: Phobeste posted:The only law of monads is that if somebody mentions the word then 10 others must appear to explain them, all slightly differently
|
# ? Jun 20, 2019 10:29 |
|
redleader posted:But then you could have gotten an equivalent mathematical introduction to monads via one of the hundred million other monad tutorials on the internet. Zeroth Monad Law, more like Rashomonad.
|
# ? Jun 20, 2019 10:34 |
|
redleader posted:But then you could have gotten an equivalent mathematical introduction to monads via one of the hundred million other monad tutorials on the internet. it's almost as though vanishingly little that human beings ever do is truly original, and we are all confused animals with illusions of free will, trying to make sense of a chaotic and capricious world.
|
# ? Jun 20, 2019 10:58 |
|
Knock knock. Who’s there? Monad Monad who? VikingofRock posted:Monads (in the Haskell sense) are types which take at least one type parameter (e.g. List<T> or Optional<T>) which implement two specific functions. (For this post I'll be using non-Haskell notation and semi-traditional names for these functions, to make things more clear.)
|
# ? Jun 20, 2019 13:16 |
|
For the record I also thought the effort explanation was nice.
|
# ? Jun 20, 2019 13:17 |
|
monads and strife,
|
# ? Jun 20, 2019 14:12 |
|
I'm pretty sure npm has given me extremely serious ptsd, in line with what soldiers returning from Vietnam must have experienced. Or maybe worse. I think all the blue haired developers working there should pay for my therapy, while a replacement is finally made. I suggest namespaces for one thing. The ability to delete repos, mainly just to discourage overuse of modules, and to encourage people to make their own forks. I think if your super popular library needed to manually stay up to date with dependencies which may or may not still exist, you'd feel encouraged to limit your use of them.
Nolgthorn fucked around with this message at 14:20 on Jun 20, 2019 |
# ? Jun 20, 2019 14:17 |
|
My only comment is that the types that participate in monadic computations aren't necessarily monads themselves. A monad is like an adapter of a particular shape which lets an arbitrary type of object participate in monadic computations (where "monadic computation" has already been sufficiently defined in this thread). In Haskell, it's common to say that a type is a particular type class when there's an instance of it defined, but in other languages that might not be true. It might be more correct to say "there is a monad for lists", and when someone says "list monad", they (should) mean "the bundle of functions and identities that allows lists to operate monadically" and not a synonym for "list type". In some languages it may be possible or necessary to explicitly pass that bundle alongside the value you're operating on monadically, giving you the opportunity to choose one of many potential monads that satisfy the monad laws. Some types such as Either[L, R] may have multiple possible monads. In the case of Either, you can hold one parameter to be fixed, which gives rise to a Maybe-like monad in one side or the other.
|
# ? Jun 20, 2019 14:55 |
|
Nolgthorn posted:His 'ansi-cyan' library is used in 223,321 other repositories. It's enough to make me quit programming. Makes me want to make an NPM clone that filters out anything tainted by his work.
|
# ? Jun 20, 2019 15:00 |
|
Vanadium posted:Nah, that's just, C++ people use functor to mean anything that can be called like a function, so also function pointers and objects that define operator(), whereas haskell people use functor to mean something utterly unrelated. I was only familiar with functor being used to mean "function object," i.e. a type that defines operator()(). Athas posted:There are two answers, depending on what you were getting at: I was asking specifically about C++ STL containers. If std:: appears in other languages, my bad. Does the STL provide equivalent methods to pure and bind that can be applied to monad types, or is that just a Haskell specific thing?
|
# ? Jun 20, 2019 15:19 |
|
I never understand when someone hates on another poster just for posting a lot of text. Like, whoever it is clearly took some effort to type it, and they expended it for free. With pure intentions. Tearing apart its mistakes is one thing but you're the rear end in a top hat if you hate on the length itself, like just don't read it if it bothers you that much obviously. It takes an incredible misanthrope to think that the inherent concept of effort is something to jump down someone's throat for, and to poo poo on it before even giving others their turn to engage it, knowing full well how it will feel for the author to have that immediate dismissal. At least those types get immediately banned in Lowtax threads when he announces something new and they try to pull that poo poo on him.
|
# ? Jun 20, 2019 15:37 |
|
zergstain posted:Does the STL provide equivalent methods to pure and bind that can be applied to monad types, or is that just a Haskell specific thing? You can easily define something like pure and bind for various C++ types, and now that C++ supports lambdas it might not even look too bad. What is more difficult is writing code that is generic over the monad that it is using. Actually, with templates it might not even be that difficult (since templates are untyped, the usual issues with higher-rank types do not crop up), but the experience will likely be painful.
|
# ? Jun 20, 2019 15:58 |
|
Athas posted:You can easily define something like pure and bind for various C++ types, and now that C++ supports lambdas it might not even look too bad. What is more difficult is writing code that is generic over the monad that it is using. Actually, with templates it might not even be that difficult (since templates are untyped, the usual issues with higher-rank types do not crop up), but the experience will likely be painful. In other words, it doesn't provide them, and if you want that functionality, you'll need to roll your own. I take it then, that the existence of those functions or equivalents aren't necessary to satisfy the definition of monad.
|
# ? Jun 20, 2019 16:25 |
|
|
# ? May 17, 2024 15:48 |
|
Munkeymon posted:Makes me want to make an NPM clone that filters out anything tainted by his work. I honestly wonder if we need something akin to a cyclomatic complexity check for dependencies in package managers.
|
# ? Jun 20, 2019 17:12 |