Logs: freenode/#haskell
| 2021-04-30 09:11:11 | × | aVikingTrex quits (~aVikingTr@120.154.33.56) (Ping timeout: 240 seconds) |
| 2021-04-30 09:13:42 | → | Guest72431 joins (~zmv@unaffiliated/zmv) |
| 2021-04-30 09:14:08 | → | ulidtko|k joins (~ulidtko@194.54.80.38) |
| 2021-04-30 09:14:46 | × | ddellacosta quits (ddellacost@gateway/vpn/mullvad/ddellacosta) (Ping timeout: 240 seconds) |
| 2021-04-30 09:14:57 | → | __monty__ joins (~toonn@unaffiliated/toonn) |
| 2021-04-30 09:16:35 | → | Nihilist joins (d4120ed2@host-212-18-14-210.customer.m-online.net) |
| 2021-04-30 09:16:41 | × | ulidtko|kk quits (~ulidtko@31.133.98.224) (Ping timeout: 240 seconds) |
| 2021-04-30 09:17:43 | × | chimera quits (~chimera@168-182-134-95.pool.ukrtel.net) (Quit: Konversation terminated!) |
| 2021-04-30 09:22:38 | → | mud joins (~mud@unaffiliated/kadoban) |
| 2021-04-30 09:23:27 | → | kritzefitz joins (~kritzefit@212.86.56.80) |
| 2021-04-30 09:24:40 | × | stree quits (~stree@68.36.8.116) (Ping timeout: 252 seconds) |
| 2021-04-30 09:31:15 | × | forell quits (~forell@unaffiliated/forell) (Ping timeout: 252 seconds) |
| 2021-04-30 09:33:45 | → | forell joins (~forell@unaffiliated/forell) |
| 2021-04-30 09:36:15 | × | sz0 quits (uid110435@gateway/web/irccloud.com/x-bwiuonpskoznguoq) (Quit: Connection closed for inactivity) |
| 2021-04-30 09:37:20 | → | stree joins (~stree@68.36.8.116) |
| 2021-04-30 09:39:57 | → | yahb joins (~yahb@haskell/bot/yahb) |
| 2021-04-30 09:40:16 | → | mniip joins (mniip@freenode/staff/mniip) |
| 2021-04-30 09:40:30 | × | Adam345 quits (~textual@2.133.253.255) (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
| 2021-04-30 09:41:23 | × | Nihilist quits (d4120ed2@host-212-18-14-210.customer.m-online.net) (Quit: Connection closed) |
| 2021-04-30 09:42:52 | → | raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) |
| 2021-04-30 09:44:15 | → | pera_ joins (~pera_@137.221.132.212) |
| 2021-04-30 09:45:25 | → | ddellacosta joins (~ddellacos@ool-44c73afa.dyn.optonline.net) |
| 2021-04-30 09:46:53 | → | DavidEichmann joins (~david@156.59.147.147.dyn.plus.net) |
| 2021-04-30 09:47:41 | × | wonko7 quits (~wonko7@62.115.229.50) (Quit: See You Space Cowboy..) |
| 2021-04-30 09:51:02 | → | ddellac__ joins (ddellacost@gateway/vpn/mullvad/ddellacosta) |
| 2021-04-30 09:51:33 | × | ddellacosta quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Ping timeout: 268 seconds) |
| 2021-04-30 09:52:17 | ← | EdwardIII parts (~edwardiii@unaffiliated/edward123) ("WeeChat 3.1") |
| 2021-04-30 09:53:03 | × | plutoniix quits (~q@node-uo8.pool-125-24.dynamic.totinternet.net) (Remote host closed the connection) |
| 2021-04-30 09:54:19 | → | shailangsa joins (~shailangs@host217-35-224-169.range217-35.btcentralplus.com) |
| 2021-04-30 09:55:02 | → | Adam345 joins (~textual@2.133.253.255) |
| 2021-04-30 09:55:17 | → | biglama joins (~alex@static-176-165-167-17.ftth.abo.bbox.fr) |
| 2021-04-30 09:55:18 | × | ddellac__ quits (ddellacost@gateway/vpn/mullvad/ddellacosta) (Ping timeout: 246 seconds) |
| 2021-04-30 09:57:21 | → | heatsink joins (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-04-30 09:59:00 | × | vicfred quits (~vicfred@unaffiliated/vicfred) (Quit: Leaving) |
| 2021-04-30 10:01:53 | → | wonko7 joins (~wonko7@62.115.229.50) |
| 2021-04-30 10:02:02 | × | heatsink quits (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 252 seconds) |
| 2021-04-30 10:05:12 | → | ekrion joins (~ffx1@181.58.39.182) |
| 2021-04-30 10:05:13 | <biglama> | Hi guys, I've written a small exception handler for HTTP request in wreq and wanted to know if the style could be improved upon : https://paste.tomsmeding.com/C7BxhvNf |
| 2021-04-30 10:05:16 | <biglama> | Thanks :) |
| 2021-04-30 10:06:37 | <[exa]> | biglama: that can be easily dosed by someone who just sends you 443 repeatedly |
| 2021-04-30 10:06:43 | <[exa]> | otherwise looks okay to me |
| 2021-04-30 10:07:41 | <biglama> | [exa]: yeah, I don't mind. It was a bit cumbersome to write the constructors so I was wondering if it could be shorter. |
| 2021-04-30 10:08:34 | <[exa]> | ah the `get` actually doesn't recurse, then it's good I guess |
| 2021-04-30 10:09:05 | <[exa]> | btw, usually you don't want to codegolf in production&reliable code :] |
| 2021-04-30 10:09:11 | ← | thblt parts (~thblt@unaffiliated/thblt) ("ERC (IRC client for Emacs 28.0.50)") |
| 2021-04-30 10:10:14 | <[exa]> | (you can be superapplicative with getRetry = liftA2 E.catch get handler) |
| 2021-04-30 10:10:21 | <biglama> | [exa]: thanks ! it's not production and not reliable, don't worry :D |
| 2021-04-30 10:10:54 | <[exa]> | (same using <$> <*>) |
| 2021-04-30 10:12:22 | <biglama> | [exa]: okay, it's a bit blurry but I get the idea. The handler function itself is as short as it can get ? |
| 2021-04-30 10:12:59 | × | acidjnk_new2 quits (~acidjnk@p200300d0c72b95722c5bb32012e463b2.dip0.t-ipconnect.de) (Ping timeout: 250 seconds) |
| 2021-04-30 10:13:05 | <biglama> | The wreq tutorial uses something like e@{StatusCodeException s _ _), which doesn't work out of the box |
| 2021-04-30 10:14:59 | → | geowiesnot joins (~user@i15-les02-ix2-87-89-181-157.sfr.lns.abo.bbox.fr) |
| 2021-04-30 10:15:21 | × | Adam345 quits (~textual@2.133.253.255) (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
| 2021-04-30 10:15:33 | <[exa]> | biglama: the handler needs to do a (slightly) complicated combination of pattern match and value check, there might be some way to write it very nicely using the pattern guards but I'm not really proficient at that |
| 2021-04-30 10:15:55 | → | nicholasbulka joins (~nicholasb@2601:900:4301:da0:f09e:8831:6f30:999f) |
| 2021-04-30 10:16:29 | → | Adam345 joins (~textual@2.133.253.255) |
| 2021-04-30 10:16:34 | <biglama> | [exa]: okay, thanks a lot ! I've been writing some haskell code for a few weeks but it's the first time I managed exceptions |
| 2021-04-30 10:16:36 | <[exa]> | structure could get close to `handler | pattern is OK, error is 443 = retry; |otherwise = throw` |
| 2021-04-30 10:17:39 | <biglama> | But I don't know how to use pattern matching with constructors though |
| 2021-04-30 10:18:47 | <[exa]> | https://wiki.haskell.org/Pattern_guard |
| 2021-04-30 10:20:27 | <biglama> | Oh :/ |
| 2021-04-30 10:22:25 | × | fendor quits (~fendor@77.119.128.145.wireless.dyn.drei.com) (Read error: Connection reset by peer) |
| 2021-04-30 10:22:43 | × | lawid quits (~quassel@2a02:8109:b5c0:5334:265e:beff:fe2a:dde8) (Ping timeout: 260 seconds) |
| 2021-04-30 10:23:18 | → | lawid joins (~quassel@2a02:8109:b5c0:5334:265e:beff:fe2a:dde8) |
| 2021-04-30 10:23:47 | <biglama> | But I can't write something like : |
| 2021-04-30 10:23:50 | <biglama> | | b == (StatusCodeException r s ) |
| 2021-04-30 10:24:36 | → | fendor joins (~fendor@77.119.128.145.wireless.dyn.drei.com) |
| 2021-04-30 10:25:23 | × | nicholasbulka quits (~nicholasb@2601:900:4301:da0:f09e:8831:6f30:999f) (Ping timeout: 248 seconds) |
| 2021-04-30 10:27:08 | × | Adam345 quits (~textual@2.133.253.255) (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
| 2021-04-30 10:28:04 | → | Adam345 joins (~textual@2.133.253.255) |
| 2021-04-30 10:29:13 | → | ddellacosta joins (ddellacost@gateway/vpn/mullvad/ddellacosta) |
| 2021-04-30 10:29:48 | <[exa]> | I thought something like this would work: `handle url e | HttpExceptionRequest _ (StatusCodeException r _) <- e, r^.responsestatus.statusCode == 443 = retry ; |otherwise=throw e` |
| 2021-04-30 10:30:11 | <biglama> | [exa]: what about this : https://paste.tomsmeding.com/q0FA1x4l ? |
| 2021-04-30 10:30:47 | <[exa]> | that's the `case` statement rewritten to guards, yes |
| 2021-04-30 10:31:07 | <[exa]> | I thought more about unifying the 2 throw cases |
| 2021-04-30 10:31:41 | <[exa]> | btw you can alias the whole exception instead of just `b@` |
| 2021-04-30 10:32:04 | <biglama> | Yeah but could not figure it out and it looked cleaner :p |
| 2021-04-30 10:32:57 | <biglama> | I don't really understand your " <- e, r ^.responseStatus" syntax. Can you write a comma like that ? |
| 2021-04-30 10:34:01 | × | ddellacosta quits (ddellacost@gateway/vpn/mullvad/ddellacosta) (Ping timeout: 260 seconds) |
| 2021-04-30 10:36:44 | <[exa]> | yeah that's the pattern guard |
| 2021-04-30 10:37:08 | <biglama> | It seems to work and looks very compact. Very nice, thanks :) |
| 2021-04-30 10:37:23 | <[exa]> | try this https://paste.tomsmeding.com/jTyTndKM |
| 2021-04-30 10:37:34 | <[exa]> | ah it worked, okay |
| 2021-04-30 10:39:46 | × | olligobber quits (olligobber@gateway/vpn/privateinternetaccess/olligobber) (Ping timeout: 240 seconds) |
| 2021-04-30 10:39:51 | <biglama> | This syntax kind of blows my mind |
| 2021-04-30 10:40:18 | <[exa]> | it's pretty much the same as list comprehension, except you know, for patterns |
| 2021-04-30 10:40:45 | <[exa]> | (also likely the implementation below is different) |
| 2021-04-30 10:41:45 | <biglama> | Does it have a name ? I would never have find that on google |
| 2021-04-30 10:43:56 | → | jamm_ joins (~jamm@unaffiliated/jamm) |
| 2021-04-30 10:44:12 | Guest72431 | is now known as notzmv |
| 2021-04-30 10:44:17 | <[exa]> | biglama: what precisely? |
| 2021-04-30 10:44:39 | <[exa]> | the syntax I used is pattern guards, see the wiki :] |
| 2021-04-30 10:46:55 | <biglama> | Indeed, dumb question :( |
| 2021-04-30 10:47:32 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 240 seconds) |
| 2021-04-30 10:47:51 | <[exa]> | biglama: ah worry not :] |
| 2021-04-30 10:49:01 | × | jamm_ quits (~jamm@unaffiliated/jamm) (Ping timeout: 276 seconds) |
| 2021-04-30 10:49:25 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-04-30 10:50:55 | <biglama> | One day, I'll read "haskell programming from first principles" from cover to end :D |
| 2021-04-30 10:53:25 | <hc> | biglama: why not do it right now, but in a non-strict way? |
| 2021-04-30 10:53:47 | <hc> | ;) |
All times are in UTC.