Logs: freenode/#haskell
| 2021-04-19 17:47:00 | → | geekosaur joins (930099da@rrcs-147-0-153-218.central.biz.rr.com) |
| 2021-04-19 17:48:49 | → | Geekingfrog joins (~geekingfr@li2156-64.members.linode.com) |
| 2021-04-19 17:51:07 | × | jamm_ quits (~jamm@unaffiliated/jamm) (Ping timeout: 260 seconds) |
| 2021-04-19 17:51:34 | → | frozenErebus joins (~frozenEre@37.231.244.249) |
| 2021-04-19 17:51:51 | → | rond_ joins (5940206b@89-64-32-107.dynamic.chello.pl) |
| 2021-04-19 17:52:31 | → | heatsink joins (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-04-19 17:52:52 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 240 seconds) |
| 2021-04-19 18:00:16 | → | MrFantastik joins (~user@rrcs-184-74-43-235.nys.biz.rr.com) |
| 2021-04-19 18:00:53 | → | safinaskar joins (~user@109.252.90.136) |
| 2021-04-19 18:01:03 | <MrFantastik> | is it possible to explain a monad to someone who has never programmed in haskell and doesn't know category theory? |
| 2021-04-19 18:01:12 | <Rembane> | MrFantastik: Yes! |
| 2021-04-19 18:01:31 | <safinaskar> | monochrom: Axman6: hi. you said yesterday that SPJ uses {}, show me some code, please :) |
| 2021-04-19 18:01:44 | <tomsmeding> | MrFantastik: by teaching them haskell :p |
| 2021-04-19 18:01:46 | <MrFantastik> | how would that go? that person is me lol |
| 2021-04-19 18:01:56 | <MrFantastik> | lmao |
| 2021-04-19 18:02:29 | <MrFantastik> | https://i.kym-cdn.com/entries/icons/original/000/011/656/sophiscated_cat.PNG |
| 2021-04-19 18:02:29 | <monochrom> | line 1: "do {". line 2: align with the "{" above, "; s <- getLine" |
| 2021-04-19 18:02:31 | → | cole-h joins (~cole-h@c-73-48-197-220.hsd1.ca.comcast.net) |
| 2021-04-19 18:02:35 | <MrFantastik> | i should learn haskell |
| 2021-04-19 18:02:37 | <tomsmeding> | I learned monads by playing around with them in haskell, and I believe for someone without a very strong mathematical background, that's the best way |
| 2021-04-19 18:03:11 | × | heatsink quits (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection) |
| 2021-04-19 18:03:19 | × | fiedlr quits (~fiedlr@83.148.33.254) (Ping timeout: 268 seconds) |
| 2021-04-19 18:03:40 | <monochrom> | err actuall no |
| 2021-04-19 18:04:05 | <tomsmeding> | I'd say the first statement is before the first ; |
| 2021-04-19 18:04:12 | <monochrom> | line 1: "do { s <- getLine". line 2: align with the "{" above, "; putStrLn s". |
| 2021-04-19 18:04:18 | → | vicfred joins (~vicfred@unaffiliated/vicfred) |
| 2021-04-19 18:04:22 | <tomsmeding> | beautiful |
| 2021-04-19 18:05:01 | <monochrom> | And at the end, "}" on its own line, aligning with that column of "{" and ";"s |
| 2021-04-19 18:05:44 | <Cale> | MrFantastik: I suppose I could try -- are you familiar with parametric data types? The most common example would be things like container data types which have a parameter for which type of elements they'd have. |
| 2021-04-19 18:06:17 | <yushyin> | safinaskar: just look at some commit from spj? |
| 2021-04-19 18:06:28 | <yushyin> | safinaskar: https://gitlab.haskell.org/ghc/ghc/-/commit/c71b220491a6ae46924cc5011b80182bcc773a58 https://gitlab.haskell.org/ghc/ghc/-/commit/0a8c14bd5a5438b1d042ad279b8ffff1bc867e7e |
| 2021-04-19 18:07:38 | <Cale> | MrFantastik: I will also say, it's probably not very useful to know much about the monad abstraction if you're not programming in a language that makes it usable. If at the end of the day, you can't really write code which would work in an arbitrary monad, then the abstraction buys you very little. |
| 2021-04-19 18:08:19 | × | ph88 quits (~ph88@2a02:8109:9e00:7e5c:d5ef:86b3:afc4:9258) (Ping timeout: 248 seconds) |
| 2021-04-19 18:08:24 | <basenode> | tomsmeding: not really honestly, i don't really know any haskell |
| 2021-04-19 18:08:37 | <MrFantastik> | Cale I'm reading https://en.wikipedia.org/wiki/Parametric_polymorphism in regards to the parameteric data types |
| 2021-04-19 18:08:52 | <MrFantastik> | your second comment is reassuring |
| 2021-04-19 18:08:58 | <tomsmeding> | basenode: I'm trying to make a fully linear version, but it involves a mutable vector somewhere :p |
| 2021-04-19 18:09:00 | <MrFantastik> | monads give me a weird sense of fomo |
| 2021-04-19 18:09:07 | <tomsmeding> | not sure you can do without if you won't accept n log n |
| 2021-04-19 18:09:17 | <basenode> | tomsmeding: as in non-recursive? |
| 2021-04-19 18:09:41 | <wroathe> | MrFantastik: They're not really that magic. They're sort of a solution to a problem that Haskell imposes on itself. Because there's no concept of a "statement" or a "step" in the computation there's no way to sequence that x should come before y. One of the things that monads do, then, is to establish sequencing by saying that some value is a _dependency_ of a computation. |
| 2021-04-19 18:09:55 | <tomsmeding> | basenode: what do you mean with recursive? that the function that builds the result should be recursive? |
| 2021-04-19 18:10:06 | <basenode> | tomsmeding: exactly |
| 2021-04-19 18:10:12 | <tomsmeding> | why do you want that? :p |
| 2021-04-19 18:10:18 | <Cale> | wroathe: I'm not sure I'd classify all monads that way |
| 2021-04-19 18:10:19 | <basenode> | tomsmeding: purity lol |
| 2021-04-19 18:10:39 | <tomsmeding> | I'm not sure what being recursive has to do with being pure, to be honest :p |
| 2021-04-19 18:10:41 | <Cale> | One particular monad is a solution to the problem that functions can't do IO, the IO monad |
| 2021-04-19 18:10:59 | <basenode> | tomsmeding: it's functional |
| 2021-04-19 18:10:59 | <Cale> | But the monad abstraction itself is useful because there are more monads than that. |
| 2021-04-19 18:11:09 | <basenode> | no mutation of state |
| 2021-04-19 18:11:12 | <Cale> | For example... |
| 2021-04-19 18:11:12 | <tomsmeding> | basenode: lots of non-recursive things are also functional :p |
| 2021-04-19 18:11:15 | <basenode> | = amazeballs |
| 2021-04-19 18:11:29 | <tomsmeding> | basenode: you can encapsulate usage of mutable state within a pure function |
| 2021-04-19 18:11:31 | <Cale> | > do x <- [1,2,3]; y <- [4,5]; return (x,y) -- lists are a monad |
| 2021-04-19 18:11:33 | <lambdabot> | [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)] |
| 2021-04-19 18:11:44 | <basenode> | tomsmeding: isn't that a type of function though? |
| 2021-04-19 18:11:45 | <wroathe> | Cale: What would be an example of a monad that doesn't follow that pattern? |
| 2021-04-19 18:11:59 | <monochrom> | Instead of asking "is it possible?", I ask "is it necessary?". |
| 2021-04-19 18:12:05 | <tomsmeding> | basenode: a function that allocates an array, does some weird stuff with it, and finally returns a pure result is a completely pure function, but it still uses mutable things inside |
| 2021-04-19 18:12:16 | <wroathe> | Cale: The old saying with IO is that there's an implicit "real world" value that comes before the next "real world" value in the sequence |
| 2021-04-19 18:12:23 | × | kuribas quits (~user@ptr-25vy0i8idggkot642u8.18120a2.ip6.access.telenet.be) (Remote host closed the connection) |
| 2021-04-19 18:12:40 | <basenode> | tomsmeding: ok, then i meant to say immutable(?) pure function |
| 2021-04-19 18:13:22 | <tomsmeding> | basenode: if you want to add the restriction that no mutation can be used in the function, then I don't think it's possible to do it in linear time, but not sure |
| 2021-04-19 18:13:33 | × | elfets quits (~elfets@ip-37-201-23-96.hsi13.unitymediagroup.de) (Ping timeout: 260 seconds) |
| 2021-04-19 18:13:38 | <monochrom> | It is unnecessary to learn monads outside Haskell unless you're interested in at least one of: C# LINQ, digging deeper into callback-style programming |
| 2021-04-19 18:13:48 | <tomsmeding> | or, hmm |
| 2021-04-19 18:14:38 | <tomsmeding> | no the paste posted earlier is not linear time when converted from maps to lists |
| 2021-04-19 18:15:09 | × | rj quits (~x@gateway/tor-sasl/rj) (Ping timeout: 240 seconds) |
| 2021-04-19 18:15:16 | <tomsmeding> | basenode: lots of things get log factors when converted to a purely functional algorithm |
| 2021-04-19 18:15:47 | <basenode> | tomsmeding: ok, i guess i'm flexible on the linear time requirement, i think the immutable state is probably more important to me |
| 2021-04-19 18:16:15 | <tomsmeding> | basenode: then the paste by ski is an answer :) |
| 2021-04-19 18:16:20 | <Cale> | wroathe: Well, the bit that I was taking issue with was saying that it's a problem that Haskell imposed on itself. Most programming languages don't have a built-in notion of parsers, or nondeterminism for example |
| 2021-04-19 18:17:04 | <Cale> | wroathe: Monad captures a pattern that is common to many libraries in a particular style of functional programming, and lets us write some common control-structure-like combinators once and share that work between all the libraries. |
| 2021-04-19 18:18:36 | → | heatsink joins (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-04-19 18:18:37 | <basenode> | tomsmeding: i just have to convert it to my daily language, i can't read haskell lol |
| 2021-04-19 18:18:46 | <tomsmeding> | basenode: which is? :p |
| 2021-04-19 18:18:47 | → | rj joins (~x@gateway/tor-sasl/rj) |
| 2021-04-19 18:18:49 | <basenode> | tomsmeding: elixir |
| 2021-04-19 18:19:02 | <MrFantastik> | its funny that lisp is the alien logo |
| 2021-04-19 18:19:13 | <MrFantastik> | because haskell is much more alien language like |
| 2021-04-19 18:19:19 | <wroathe> | Cale: That's the interface component of the Monad typeclass. ski and I were having a good conversation about this the other day. We landed on a few different angles for explaining monads to beginners: 1. Monads as a "box" (the most hand-wavy level), 2. Monads as programmable semicolons (the angle I was just tackling) and 3. The Monad typeclass as an interface like you might think of in any language that |
| 2021-04-19 18:19:25 | <wroathe> | supports interfaces |
| 2021-04-19 18:19:32 | <tomsmeding> | basenode: ski's solution uses haskell's laziness quite crucially though |
| 2021-04-19 18:19:59 | <wroathe> | I think ski might have mentioned one more angle |
| 2021-04-19 18:20:01 | <basenode> | tomsmeding: ah, then it that case it probably won't be too useful, otherwise i can't translate it |
| 2021-04-19 18:20:23 | <tomsmeding> | wroathe: perhaps monads as a computation? or is that nr. 1? |
| 2021-04-19 18:20:39 | <monochrom> | that's 2 |
| 2021-04-19 18:20:56 | <monochrom> | programmable semicolon |
| 2021-04-19 18:21:00 | <tomsmeding> | I guess |
| 2021-04-19 18:21:01 | × | star_cloud quits (~star_clou@ec2-34-220-44-120.us-west-2.compute.amazonaws.com) (Ping timeout: 260 seconds) |
| 2021-04-19 18:21:33 | <monochrom> | Moggi would prefer programmable let-in but meh |
| 2021-04-19 18:21:39 | <tomsmeding> | though you can see the list monad [a] also as a computation that produces an a nondeterminstically, with a bit of squinting |
| 2021-04-19 18:21:42 | <Cale> | MrFantastik: I think it helps to have some examples, because "monad" is an abstraction, and if you don't already know any examples of the kind of thing it's abstracting over, it's not going to make sense, even though the actual content of what it is, is quite simple. |
| 2021-04-19 18:22:04 | → | hiroaki_ joins (~hiroaki@2a02:8108:8c40:2bb8:bd38:fd76:9bf:a5f) |
| 2021-04-19 18:22:05 | × | ddellaco_ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Remote host closed the connection) |
| 2021-04-19 18:22:06 | × | frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 240 seconds) |
| 2021-04-19 18:22:11 | <MrFantastik> | i've looked at some examples and have still very little understanding |
| 2021-04-19 18:22:34 | <MrFantastik> | i think they will impossible for me to understand until I need to use one |
All times are in UTC.