Logs: liberachat/#haskell
| 2021-05-28 18:48:17 | × | unyu quits (~pyon@user/pyon) (Quit: WeeChat 3.1) |
| 2021-05-28 18:49:17 | → | werneta joins (~werneta@70-142-214-115.lightspeed.irvnca.sbcglobal.net) |
| 2021-05-28 18:49:32 | <sm[m]> | heh, it's weird isn't it |
| 2021-05-28 18:49:36 | <davean> | monochrom: Your department, but I don't mind if you slack |
| 2021-05-28 18:52:12 | <dminuoso> | Mmm, is there a reason ApplicativeDo wont let me write `do (f,g) <- foo; ...` ? |
| 2021-05-28 18:52:25 | <glguy> | dminuoso: try: ~(f,g) <- |
| 2021-05-28 18:52:43 | <davean> | So irrifutable |
| 2021-05-28 18:52:44 | <dminuoso> | glguy: Works like a charm! |
| 2021-05-28 18:52:56 | → | bfrk joins (~Thunderbi@200116b84508c2004c8614311807bd60.dip.versatel-1u1.de) |
| 2021-05-28 18:53:00 | <dminuoso> | glguy: Cheers. By the way, config-schema is making its way to my favourite library this year. :) |
| 2021-05-28 18:53:12 | <glguy> | yay! |
| 2021-05-28 18:53:34 | <glguy> | what're you up to with it? |
| 2021-05-28 18:54:08 | <dminuoso> | Just startup configuration for some services, switching all to config-schema because I get way more expressivity and free docs along the way. :) |
| 2021-05-28 18:55:11 | → | Erutuon joins (~Erutuon@97-116-14-180.mpls.qwest.net) |
| 2021-05-28 18:55:31 | <glguy> | let me know if you run into rough edges |
| 2021-05-28 18:56:09 | × | wagle quits (~wagle@quassel.wagle.io) (Ping timeout: 272 seconds) |
| 2021-05-28 18:56:39 | × | fizbin quits (~fizbin@c-73-33-197-160.hsd1.nj.comcast.net) (Remote host closed the connection) |
| 2021-05-28 18:56:41 | <dminuoso> | Is there a particular reason why making the above match irrefutable helps? Or is this just one of those ApplicativeDo bugs? |
| 2021-05-28 18:57:18 | <geekosaur> | MonadFail interaction? |
| 2021-05-28 18:57:21 | <glguy> | yeah |
| 2021-05-28 18:57:24 | <dminuoso> | Ah |
| 2021-05-28 18:57:29 | <glguy> | err |
| 2021-05-28 18:57:41 | <int-e> | why though? (f,g) should be in the non-failable pattern category |
| 2021-05-28 18:57:50 | × | waleee quits (~waleee@2001:9b0:216:8200:d457:9189:7843:1dbd) (Ping timeout: 248 seconds) |
| 2021-05-28 18:58:02 | <glguy> | I think the issue is that in do-notation normally the pattern match would be forced earlier |
| 2021-05-28 18:58:02 | → | fizbin joins (~fizbin@c-73-33-197-160.hsd1.nj.comcast.net) |
| 2021-05-28 18:58:22 | <glguy> | do (x,y) <- m; f x y -> m >>= \p -> case p of (x,y) -> f x y |
| 2021-05-28 18:58:34 | × | superbil quits (~superbil@1-34-176-171.HINET-IP.hinet.net) (Quit: WeeChat 3.1) |
| 2021-05-28 18:58:36 | <shachaf> | I don't think you can translate it to Applicative with the refutable pattern. |
| 2021-05-28 18:58:41 | <glguy> | but you can't do that with <*> |
| 2021-05-28 18:58:54 | <int-e> | ah, so there's a subtle difference in strictness. true. |
| 2021-05-28 18:59:12 | <dminuoso> | ah fair enough |
| 2021-05-28 18:59:12 | <glguy> | but how would you write that with <*>? |
| 2021-05-28 18:59:18 | × | danidiaz quits (~ESDPC@static-203-177-6-89.ipcom.comunitel.net) (Quit: Leaving.) |
| 2021-05-28 18:59:25 | <glguy> | wow, bad example |
| 2021-05-28 18:59:30 | <glguy> | because I used x and y |
| 2021-05-28 18:59:31 | <int-e> | and ~(f,g) expresses the difference visibly |
| 2021-05-28 18:59:48 | <glguy> | but still you'd have something like: (\(x,y) -> stuff) <$> m <*> m2 |
| 2021-05-28 19:00:00 | → | wagle joins (~wagle@quassel.wagle.io) |
| 2021-05-28 19:00:04 | <glguy> | where the match on (x,y) happens later/not-at-all |
| 2021-05-28 19:00:32 | → | econo joins (uid147250@user/econo) |
| 2021-05-28 19:00:43 | <shachaf> | But in the monad case the m2 effects wouldn't happen if m fails. |
| 2021-05-28 19:00:54 | <shachaf> | I mean, in the refutable case. |
| 2021-05-28 19:01:07 | <int-e> | if m succeeds with a bottom result |
| 2021-05-28 19:01:12 | × | lbseale quits (~lbseale@ip72-194-54-201.sb.sd.cox.net) (Read error: Connection reset by peer) |
| 2021-05-28 19:01:15 | <shachaf> | Right. |
| 2021-05-28 19:01:47 | × | Guest31 quits (~textual@cpc146410-hari22-2-0-cust124.20-2.cable.virginm.net) (Quit: Textual IRC Client: www.textualapp.com) |
| 2021-05-28 19:02:22 | → | waleee joins (~waleee@2001:9b0:216:8200:d457:9189:7843:1dbd) |
| 2021-05-28 19:02:39 | × | Bartosz quits (~textual@50.35.215.151) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2021-05-28 19:03:29 | <monochrom> | IIRC general "pattern <- expr" require as far as MonadFail |
| 2021-05-28 19:03:45 | → | dunham joins (~dunham@97-113-35-16.tukw.qwest.net) |
| 2021-05-28 19:03:52 | <shachaf> | I guess you could test whether it works with newtype. |
| 2021-05-28 19:03:59 | × | bfrk quits (~Thunderbi@200116b84508c2004c8614311807bd60.dip.versatel-1u1.de) (Quit: bfrk) |
| 2021-05-28 19:04:07 | → | bfrk1 joins (~Thunderbi@200116b84508c2004c8614311807bd60.dip.versatel-1u1.de) |
| 2021-05-28 19:04:21 | <int-e> | monochrom: (x,y) <- foo doesn't; there's an exemption for single-constructor datatypes, basically |
| 2021-05-28 19:04:36 | <monochrom> | and IIRC up to now the compiler won't walk the extra mile of "but (x,y) has only one case, this is overkill" |
| 2021-05-28 19:04:44 | <monochrom> | Oh oops sorry. |
| 2021-05-28 19:04:49 | <shachaf> | Oh, huh. |
| 2021-05-28 19:05:04 | <shachaf> | Even a newtype requires a ~. |
| 2021-05-28 19:05:18 | <shachaf> | I vaguely remember that the rules around this were complicated, but is there a reason? |
| 2021-05-28 19:05:26 | <int-e> | shachaf: okay, that is surprising (for ApplicativeDo I assume) |
| 2021-05-28 19:05:38 | <shachaf> | Yes. |
| 2021-05-28 19:05:47 | → | Bartosz joins (~textual@50.35.215.151) |
| 2021-05-28 19:05:47 | <dminuoso> | shachaf: Perhaps because newtypes go through the same desugaring as data here? |
| 2021-05-28 19:05:52 | × | [Kalisto] quits (~Nico@user/kalisto/x-8968079) (Quit: The Lounge - https://thelounge.chat) |
| 2021-05-28 19:06:07 | → | [Kalisto] joins (~Nico@user/kalisto/x-8968079) |
| 2021-05-28 19:06:16 | <dminuoso> | I recall a similar story when we were discussing the `undefined { getSum = 42 }` story |
| 2021-05-28 19:06:19 | <monochrom> | I guess bottomness still matters. |
| 2021-05-28 19:06:24 | <shachaf> | But I would sort of imagine that whether the match is strict wouldn't just be syntactic. |
| 2021-05-28 19:06:28 | bfrk1 | is now known as bfrk |
| 2021-05-28 19:06:32 | <int-e> | understandable maybe, because insisting on ~ for ~(x,y) <- foo is a bit artificial. |
| 2021-05-28 19:06:46 | <shachaf> | Is there a difference between ~(Identity x) and (Identity x) as patterns in this context? |
| 2021-05-28 19:07:15 | <int-e> | shachaf: there isn't supposed to be any semantic difference, no |
| 2021-05-28 19:07:45 | <shachaf> | I think the thing I'm thinking about is the difference between strict data and newtype. |
| 2021-05-28 19:07:54 | <shachaf> | But presumably newtype is the case where this should just work. |
| 2021-05-28 19:07:58 | <shachaf> | Oh well. |
| 2021-05-28 19:08:13 | → | superbil joins (~superbil@1-34-176-171.HINET-IP.hinet.net) |
| 2021-05-28 19:08:15 | → | ikex joins (~ash@user/ikex) |
| 2021-05-28 19:08:54 | × | justsomeguy quits (~justsomeg@user/justsomeguy) (Quit: WeeChat 3.0.1) |
| 2021-05-28 19:09:21 | → | ixlun` joins (~user@109.249.184.235) |
| 2021-05-28 19:09:36 | <int-e> | shachaf: I imagine it's as simple as ApplicativeDo refusing to do *any* pattern matching except by irrefutable patterns. |
| 2021-05-28 19:10:01 | ixlun` | is now known as ixlun |
| 2021-05-28 19:10:15 | <int-e> | So you get a syntactic restriction that all patterns must have a ~. |
| 2021-05-28 19:10:38 | <int-e> | (or be variable patterns) |
| 2021-05-28 19:10:45 | <shachaf> | But a newtype pattern is irrefutable. |
| 2021-05-28 19:10:50 | <shachaf> | I guess it might just be a syntactic check. |
| 2021-05-28 19:11:23 | ← | [Kalisto] parts (~Nico@user/kalisto/x-8968079) (The Lounge - https://thelounge.chat) |
| 2021-05-28 19:11:27 | <ixlun> | Hi all. Quick question. If I'm in the 'ExceptT String IO ()' monad and I've got a function that returns 'IO (Either String Int)', how can I lift this function but also apply error handling to the Either? |
| 2021-05-28 19:12:00 | <shachaf> | I checked the report: «The irrefutable patterns are as follows: a variable, a wildcard, N apat where N is a constructor defined by newtype and apat is irrefutable (see Section 4.2.3), var@apat where apatis irrefutable, or of the form ~apat (whether or not apat is irrefutable). All other patterns are refutable.» |
| 2021-05-28 19:12:39 | <shachaf> | Seems like an easy enough check to do at ApplicativeDo expansion time. Presumably it should just do that. |
| 2021-05-28 19:13:02 | <int-e> | Sure, I agree. |
| 2021-05-28 19:13:52 | <int-e> | I'm just rationalizing existing behavior... basically convincing myself (and maybe others) that it's probably not a bug. |
| 2021-05-28 19:14:01 | × | ddellacosta quits (~ddellacos@86.106.121.23) (Remote host closed the connection) |
| 2021-05-28 19:14:30 | → | ddellacosta joins (~ddellacos@86.106.121.23) |
| 2021-05-28 19:14:41 | <int-e> | It's still a wart that could be remedied. |
| 2021-05-28 19:14:47 | → | Morrow joins (~MorrowM_@bzq-110-168-31-106.red.bezeqint.net) |
| 2021-05-28 19:15:26 | × | dunham quits (~dunham@97-113-35-16.tukw.qwest.net) (Ping timeout: 248 seconds) |
| 2021-05-28 19:15:42 | <tomsmeding> | @unmtl ExceptT String IO () |
| 2021-05-28 19:15:42 | <lambdabot> | IO (Either String ()) |
| 2021-05-28 19:16:08 | <tomsmeding> | :t ExceptT |
All times are in UTC.