Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-03-13 07:08:47 <dmwit> (i.e. there are plenty of long-term but low-impact projects that don't want it)
2021-03-13 07:09:24 <infinisil> dmwit: I think it could still be explicit then, like using a partial `ignoreError :: Either e a -> a`
2021-03-13 07:10:35 <dmwit> So you would want some blessed collection of exceptions which did not have to appear in the type signature?
2021-03-13 07:11:04 <infinisil> Hm no?
2021-03-13 07:11:06 <dmwit> (Or what choice of "partial" do you make here, if not "throws an exception"? "loops"?)
2021-03-13 07:11:36 <infinisil> Imagine a hackage where every library returns an Either in case of an error (or something equivalent)
2021-03-13 07:11:49 <infinisil> Exceptions don't exist
2021-03-13 07:12:09 <dmwit> So, operationally, what does your ignoreError do, if not throw an exception?
2021-03-13 07:12:32 <infinisil> `error`'s out, uncatchable, panics
2021-03-13 07:12:48 <dmwit> That's... what an exception is.
2021-03-13 07:12:55 <infinisil> exceptions are catchable
2021-03-13 07:13:03 dmwit shrugs
2021-03-13 07:13:06 <dmwit> If you say so.
2021-03-13 07:13:16 × juri_ quits (~juri@178.63.35.222) (Ping timeout: 240 seconds)
2021-03-13 07:13:21 <infinisil> Well I guess technically it might still be an exception in the rts
2021-03-13 07:13:31 <infinisil> But it's not exposed in Haskell
2021-03-13 07:13:44 <infinisil> Calling `error` just stops the program
2021-03-13 07:14:17 <infinisil> But anyways, `ignoreError` would just be a way to ignore the errors if somebody doesn't want to care about them in a quick and dirty project
2021-03-13 07:15:17 <infinisil> Nothing I'd encourage using of course, the focus should be on Either (or something equivalent/better) handling and bubbling up
2021-03-13 07:15:35 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-03-13 07:15:51 <dmwit> I suspect if you did that you'd just replay the history we've already gone through. Some libraries would cheat and use it when they shouldn't, and then people would demand a way to catch these things so they could deal with cheating libraries, and then we'd find out we wanted structured exceptions and not just (), and then we'd be back where we are now.
2021-03-13 07:16:41 <dmwit> There's also a separate line about interrupting other threads and stuff.
2021-03-13 07:17:11 <infinisil> Would history repeat itself if there was a very convenient way to bubble up errors though?
2021-03-13 07:18:44 <dmwit> Probably. There's plenty of libraries on Hackage that go out of their way to cheat with the mechanisms for cheating we already have, even though the non-cheating version is more convenient.
2021-03-13 07:19:18 <infinisil> What if there was a GHC extension
2021-03-13 07:20:11 <dmwit> What does the extension do, and what problem is that solving?
2021-03-13 07:20:17 <infinisil> Something like "automatically open union all errors in do notation"
2021-03-13 07:20:29 juri_ joins (~juri@178.63.35.222)
2021-03-13 07:20:37 <infinisil> Or idk, infer the type of a function based on that
2021-03-13 07:20:50 <infinisil> Without the user having to annotate it
2021-03-13 07:20:51 <infinisil> Idk
2021-03-13 07:21:31 <infinisil> But I have hope that there's *something* that could be done to have nice ergonomics, whether it be a library or a change in GHC itself
2021-03-13 07:21:46 monadmatt joins (~user@119-17-128-101.771180.mel.nbn.aussiebb.net)
2021-03-13 07:21:50 × waleee-cl quits (uid373333@gateway/web/irccloud.com/x-ztluuxltoyaaemrx) (Quit: Connection closed for inactivity)
2021-03-13 07:21:53 <infinisil> I shall now read https://www.fpcomplete.com/blog/error-handling-is-hard/
2021-03-13 07:22:00 <dmwit> heh
2021-03-13 07:27:04 × monadmatt quits (~user@119-17-128-101.771180.mel.nbn.aussiebb.net) (Ping timeout: 276 seconds)
2021-03-13 07:27:59 arrowsvc_ joins (~arr@2.93.163.35)
2021-03-13 07:30:59 infinisil now reads https://www.parsonsmatt.org/2020/01/03/plucking_constraints.html
2021-03-13 07:38:16 ddellacosta joins (ddellacost@gateway/vpn/mullvad/ddellacosta)
2021-03-13 07:39:45 slac36247 is now known as slack1256
2021-03-13 07:40:18 monadmatt joins (~user@119-17-128-101.771180.mel.nbn.aussiebb.net)
2021-03-13 07:43:19 × ddellacosta quits (ddellacost@gateway/vpn/mullvad/ddellacosta) (Ping timeout: 276 seconds)
2021-03-13 07:43:57 kam1 joins (~kam1@83.123.154.198)
2021-03-13 07:45:22 × monadmatt quits (~user@119-17-128-101.771180.mel.nbn.aussiebb.net) (Ping timeout: 256 seconds)
2021-03-13 07:45:24 × slack1256 quits (~slack1256@dvc-186-186-101-190.movil.vtr.net) (Remote host closed the connection)
2021-03-13 07:48:13 × mmohammadi9812 quits (~mmohammad@2.178.240.243) (Quit: Leaving)
2021-03-13 07:49:33 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 246 seconds)
2021-03-13 07:49:38 coot joins (~coot@37.30.55.141.nat.umts.dynamic.t-mobile.pl)
2021-03-13 07:49:46 × tzh quits (~tzh@c-24-21-73-154.hsd1.or.comcast.net) (Quit: zzz)
2021-03-13 07:56:07 forgottenone joins (~forgotten@176.42.24.172)
2021-03-13 07:57:38 × borne quits (~fritjof@200116b86494d2006eea3fb954ab8361.dip.versatel-1u1.de) (Ping timeout: 264 seconds)
2021-03-13 07:57:41 plutoniix joins (~q@node-uj8.pool-125-24.dynamic.totinternet.net)
2021-03-13 07:58:53 aggin joins (~ecm@103.88.87.21)
2021-03-13 08:00:01 magnuscake joins (~magnuscak@87-121-92-61.dyn.launtel.net.au)
2021-03-13 08:02:04 <magnuscake> Hey peeps
2021-03-13 08:02:14 <magnuscake> Folds are giving me such a hard time :(
2021-03-13 08:02:16 <magnuscake> Anyways
2021-03-13 08:02:17 <magnuscake> https://paste.tomsmeding.com/SGdQKBdk
2021-03-13 08:02:19 <dmwit> o/
2021-03-13 08:02:46 <magnuscake> I am having a hard time understanding everything after the `where` part
2021-03-13 08:03:07 <magnuscake> I understand what its doing
2021-03-13 08:03:09 × matryoshka quits (~matryoshk@2606:6080:1002:8:3285:30e:de43:8809) (Ping timeout: 272 seconds)
2021-03-13 08:03:24 <magnuscake> But I can't understand how
2021-03-13 08:03:58 <dmwit> Yikes, this code is... not good.
2021-03-13 08:04:07 <dmwit> Anyway we should be able to get you to where you understand it.
2021-03-13 08:04:23 <magnuscake> I saw a couple of instances of the same code from different people
2021-03-13 08:04:38 × frozenErebus quits (~frozenEre@94.128.82.20) (Ping timeout: 256 seconds)
2021-03-13 08:04:44 <magnuscake> So my question is
2021-03-13 08:04:54 <dmwit> FWIW I would filterDbDate items = [date | DbDate date <- items].
2021-03-13 08:05:12 <magnuscake> Yeah of course that makes a lot more sense
2021-03-13 08:05:20 <magnuscake> But in this case, we have to use folds
2021-03-13 08:05:30 × aggin quits (~ecm@103.88.87.21) (Quit: WeeChat 3.0.1)
2021-03-13 08:05:40 <magnuscake> How does that getDate thing work
2021-03-13 08:05:41 <dmwit> Even if you must use a fold this can be done in various better ways. But never mind.
2021-03-13 08:05:46 <magnuscake> I didn't know that was valid syntax
2021-03-13 08:05:57 <dmwit> Hm, which bit of syntax surprises you, exactly?
2021-03-13 08:06:29 <magnuscake> So I get `getDate` is the function to apply to the list values
2021-03-13 08:06:38 <dmwit> Right.
2021-03-13 08:06:41 <magnuscake> But how does the whole
2021-03-13 08:06:51 × kam1 quits (~kam1@83.123.154.198) (Read error: Connection reset by peer)
2021-03-13 08:06:52 <magnuscake> getDate (DbDate date) xs =...
2021-03-13 08:06:59 <magnuscake> Work?
2021-03-13 08:07:03 <magnuscake> Sorry for being too general
2021-03-13 08:07:12 <dmwit> Is it the `(DbDate date)` bit that's surprising you?
2021-03-13 08:07:21 <dmwit> If so, it's called pattern matching.
2021-03-13 08:07:29 × jathan quits (~jathan@69.61.93.38) (Quit: WeeChat 2.3)
2021-03-13 08:07:36 <magnuscake> Oh yes I undertand that
2021-03-13 08:07:41 <dmwit> Hm, okay.
2021-03-13 08:07:58 <magnuscake> So taking the example of a case in Haskell
2021-03-13 08:08:08 <magnuscake> If a certain statement is true
2021-03-13 08:08:09 <dmwit> Well, there's... really not much more to `getDate (DbDate date) xs =` than that. `DbDate date` is a pattern match, `xs` is a pattern match. That's it.
2021-03-13 08:08:32 <magnuscake> So does it mean
2021-03-13 08:09:01 <magnuscake> foldr getDate (DbDate date) xs
2021-03-13 08:09:15 <magnuscake> As in when the function finds a valid pattern?
2021-03-13 08:09:36 <dmwit> Hm, no, this function is applied to every element of the list.
2021-03-13 08:09:46 <dmwit> If the `DbDate date` pattern doesn't match, it proceeds to the next line.
2021-03-13 08:09:51 <dmwit> (And the next line always matches.)
2021-03-13 08:09:57 × xff0x quits (~xff0x@2001:1a81:5243:ae00:c201:8f39:a8f8:4489) (Ping timeout: 260 seconds)
2021-03-13 08:10:30 <magnuscake> Ok. And what about the xs ++ [date] at the end

All times are in UTC.