Logs: freenode/#haskell
| 2020-10-07 08:45:27 | × | xff0x_ quits (~fox@2001:1a81:5374:e100:2800:5137:cbd5:b8c6) (Ping timeout: 240 seconds) |
| 2020-10-07 08:45:33 | <tomsmeding> | 2020, the year in which triples have four elements |
| 2020-10-07 08:46:06 | → | LKoen joins (~LKoen@81.255.219.130) |
| 2020-10-07 08:46:31 | → | xff0x_ joins (~fox@2001:1a81:5374:e100:90a4:ed3f:c45e:9759) |
| 2020-10-07 08:47:56 | → | ixlun joins (~matthew@213.205.241.94) |
| 2020-10-07 08:49:46 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 272 seconds) |
| 2020-10-07 08:52:15 | <maerwald> | dminuoso: 3 |
| 2020-10-07 08:52:31 | <maerwald> | "unknown-linux" is one :p |
| 2020-10-07 08:52:37 | <kuribas> | > length (1, 2, (3, 4)) |
| 2020-10-07 08:52:39 | <lambdabot> | error: |
| 2020-10-07 08:52:39 | <lambdabot> | • No instance for (Foldable ((,,) Integer Integer)) |
| 2020-10-07 08:52:39 | <lambdabot> | arising from a use of ‘length’ |
| 2020-10-07 08:52:47 | <kuribas> | > length (1, (2, (3, 4))) |
| 2020-10-07 08:52:49 | <lambdabot> | 1 |
| 2020-10-07 08:53:55 | × | shatriff quits (~vitaliish@217.27.153.240) (Ping timeout: 256 seconds) |
| 2020-10-07 08:55:53 | × | hnOsmium0001 quits (uid453710@gateway/web/irccloud.com/x-wkoagvlxhlhmtgti) (Quit: Connection closed for inactivity) |
| 2020-10-07 08:56:44 | <dminuoso> | maerwald: Oh I know. ;) |
| 2020-10-07 08:58:11 | <dminuoso> | kuribas: There's a debatable `instance Foldable ((,) a)` |
| 2020-10-07 08:58:19 | <dminuoso> | But it doesn't exist for longer tuples |
| 2020-10-07 08:58:53 | <kuribas> | :t length |
| 2020-10-07 08:58:54 | <lambdabot> | Foldable t => t a -> Int |
| 2020-10-07 08:59:32 | <dminuoso> | The idea is that `(a,)` is a Foldable if we think of it as a 1-element container with some extra baggage. :p |
| 2020-10-07 09:00:29 | × | ttc quits (tomtauma1@gateway/shell/matrix.org/x-jhgolvjpuztnuiul) (Quit: Idle for 30+ days) |
| 2020-10-07 09:01:13 | → | thir joins (~thir@p200300f27f0fc60038c1b16891cbfa03.dip0.t-ipconnect.de) |
| 2020-10-07 09:02:03 | × | wangoe[m] quits (wangoematr@gateway/shell/matrix.org/x-ygktxbgtoupbgdmu) (Quit: Idle for 30+ days) |
| 2020-10-07 09:02:22 | ← | gcoakes[m] parts (gcoakesmat@gateway/shell/matrix.org/x-klflsytbyxwgnxns) ("Kicked by @appservice-irc:matrix.org : Idle for 30+ days") |
| 2020-10-07 09:02:58 | <kuribas> | > (1, 2, (3, 4)) ..^ (folded . to length) |
| 2020-10-07 09:03:00 | <lambdabot> | error: |
| 2020-10-07 09:03:00 | <lambdabot> | • Variable not in scope: |
| 2020-10-07 09:03:00 | <lambdabot> | (..^) |
| 2020-10-07 09:03:12 | <kuribas> | > (1, 2, (3, 4)) ^.. (folded . to length) |
| 2020-10-07 09:03:15 | <lambdabot> | error: |
| 2020-10-07 09:03:15 | <lambdabot> | • No instance for (Foldable ((,,) Integer Integer)) |
| 2020-10-07 09:03:15 | <lambdabot> | arising from a use of ‘folded’ |
| 2020-10-07 09:03:38 | → | DavidEichmann joins (~david@43.240.198.146.dyn.plus.net) |
| 2020-10-07 09:03:46 | <kuribas> | dminuoso: the type system prevents any other instance for tuple. |
| 2020-10-07 09:04:28 | <dminuoso> | Huh? |
| 2020-10-07 09:04:42 | <dminuoso> | We can write `instance Foldable ((,,) a b) where ...` just fine |
| 2020-10-07 09:04:54 | → | ahmr88 joins (~ahmr88@cpc85006-haye22-2-0-cust131.17-4.cable.virginm.net) |
| 2020-10-07 09:05:27 | × | thir quits (~thir@p200300f27f0fc60038c1b16891cbfa03.dip0.t-ipconnect.de) (Ping timeout: 240 seconds) |
| 2020-10-07 09:05:35 | × | tsrt^ quits (tsrt@ip98-184-89-2.mc.at.cox.net) () |
| 2020-10-07 09:06:48 | <kuribas> | I mean for 2 tuple |
| 2020-10-07 09:07:15 | → | ffl^ joins (ffl@ip98-184-89-2.mc.at.cox.net) |
| 2020-10-07 09:08:02 | <dminuoso> | kuribas: Just because it's possible to write an instance, it doesn't make it good. |
| 2020-10-07 09:08:17 | <dminuoso> | I think the `Foldable ((,) a)` instance shouldn't exist at all |
| 2020-10-07 09:08:26 | × | mmohammadi981266 quits (~mmohammad@5.238.172.236) (Ping timeout: 256 seconds) |
| 2020-10-07 09:08:44 | <dminuoso> | It will just type check for the odd `foldMap f g` and very likely do something unexpected. |
| 2020-10-07 09:08:51 | <kuribas> | it doesn't look that useful. |
| 2020-10-07 09:09:07 | × | __skn quits (~sunil@sec.nimmagadda.net) (Quit: ZNC 1.7.1 - https://znc.in) |
| 2020-10-07 09:09:31 | <dminuoso> | I mean if I did `sum (10,20)` I'd naively expect that to yield 30 or not type check. |
| 2020-10-07 09:09:36 | <dminuoso> | Instead I get `20` |
| 2020-10-07 09:09:45 | → | todda7 joins (~torstein@athedsl-4367507.home.otenet.gr) |
| 2020-10-07 09:09:47 | <dminuoso> | Principle of maximum surprise. :) |
| 2020-10-07 09:09:56 | <kuribas> | dminuoso: but that sum is more polymorphic |
| 2020-10-07 09:10:17 | <dminuoso> | So? |
| 2020-10-07 09:10:46 | <ptrcmd> | > sum (10, 20) |
| 2020-10-07 09:10:49 | <lambdabot> | 20 |
| 2020-10-07 09:10:54 | <ptrcmd> | lol |
| 2020-10-07 09:11:02 | <kuribas> | how do you sum ("10", 20)? |
| 2020-10-07 09:11:15 | × | alp quits (~alp@2a01:e0a:58b:4920:18a9:ec9:c879:c1d7) (Remote host closed the connection) |
| 2020-10-07 09:11:34 | → | alp joins (~alp@2a01:e0a:58b:4920:3027:b807:1b0e:5ebe) |
| 2020-10-07 09:12:18 | → | __monty__ joins (~toonn@unaffiliated/toonn) |
| 2020-10-07 09:12:25 | <dminuoso> | It's sort of how `lens` allows you to view through a Traversal. |
| 2020-10-07 09:12:37 | <dminuoso> | I mean yeah, there's a sensible implementation, but it likely doesn't do what you think it does. |
| 2020-10-07 09:13:19 | <dminuoso> | % [Product 10, Product 20, Product 30] ^. each |
| 2020-10-07 09:13:19 | <yahb> | dminuoso: Product {getProduct = 6000} |
| 2020-10-07 09:14:30 | <dminuoso> | Sometimes leaving out an obvious implementation helps avoid people trip into bugs because the code type checks and does something very unexpected. |
| 2020-10-07 09:15:33 | <kuribas> | % (Sum 10, Sum 20) ^. each |
| 2020-10-07 09:15:33 | <yahb> | kuribas: Sum {getSum = 30} |
| 2020-10-07 09:15:53 | <dminuoso> | If you consider something less obvious like |
| 2020-10-07 09:16:11 | × | bor0 quits (~boro@unaffiliated/boro/x-000000001) (Quit: Leaving) |
| 2020-10-07 09:16:16 | <dminuoso> | % [Left 'f', Right 1, Left 'o', Right 2, Left 'o'] ^. each._Left |
| 2020-10-07 09:16:16 | <yahb> | dminuoso: ; <interactive>:71:53: error:; * No instance for (Monoid Char) arising from a use of `each'; * In the first argument of `(.)', namely `each'; In the second argument of `(^.)', namely `each . _Left'; In the expression: [Left 'f', Right 1, Left 'o', Right 2, ....] ^. each . _Left |
| 2020-10-07 09:16:16 | <kuribas> | :t each |
| 2020-10-07 09:16:19 | <lambdabot> | (Each s t a b, Applicative f) => (a -> f b) -> s -> f t |
| 2020-10-07 09:16:37 | <dminuoso> | But then do something like |
| 2020-10-07 09:16:50 | <dminuoso> | % [Left "f", Right 1, Left "o", Right 2, Left "o"] ^. (each._Left) |
| 2020-10-07 09:16:50 | <yahb> | dminuoso: "foo" |
| 2020-10-07 09:17:13 | <dminuoso> | It's not very obvious what's happening. Especially because `(^.)` doesnt make that obvious |
| 2020-10-07 09:17:33 | <dminuoso> | (^.) :: s -> Getting a s a -> a |
| 2020-10-07 09:17:37 | <dminuoso> | type Getting r s a = (a -> Const r a) -> s -> Const r s |
| 2020-10-07 09:17:48 | <dminuoso> | And then, if you stare at the above Applicative constraint |
| 2020-10-07 09:17:50 | <dminuoso> | you get |
| 2020-10-07 09:18:00 | <dminuoso> | instance Monoid m => Applicative (Const m :: Type -> Type) |
| 2020-10-07 09:18:21 | <dminuoso> | So yeah. Everything works out somehow |
| 2020-10-07 09:18:39 | → | mmohammadi981266 joins (~mmohammad@5.238.172.236) |
| 2020-10-07 09:19:15 | × | alp quits (~alp@2a01:e0a:58b:4920:3027:b807:1b0e:5ebe) (Read error: Connection reset by peer) |
| 2020-10-07 09:19:23 | <kuribas> | lenses leaky abstractions |
| 2020-10-07 09:19:27 | <dminuoso> | Which is one of the reasons I like optics more |
| 2020-10-07 09:19:33 | <dminuoso> | optics just flat out fails with a type error on that one |
| 2020-10-07 09:19:35 | → | alp joins (~alp@2a01:e0a:58b:4920:3027:b807:1b0e:5ebe) |
| 2020-10-07 09:19:40 | <dminuoso> | And forces you to use a fold explicitly if you wanted that |
| 2020-10-07 09:20:46 | → | ubert joins (~Thunderbi@2a02:8109:9880:303c:ca5b:76ff:fe29:f233) |
| 2020-10-07 09:24:57 | <tomjaguarpaw> | I've been bitten by (^.) doing mconcat on the targets. I wish they hadn't supported that (but instead provided a different combinator that does do that. "mconcatOf" would have been fine). |
| 2020-10-07 09:25:38 | × | bahamas quits (~lucian@unaffiliated/bahamas) (Ping timeout: 260 seconds) |
| 2020-10-07 09:29:35 | → | shatriff joins (~vitaliish@88.155.140.206) |
| 2020-10-07 09:31:05 | × | oxide quits (~lambda@unaffiliated/mclaren) (Ping timeout: 240 seconds) |
| 2020-10-07 09:31:49 | → | seanvert joins (~user@177.84.244.242) |
| 2020-10-07 09:36:00 | × | GyroW quits (~GyroW@unaffiliated/gyrow) (Ping timeout: 272 seconds) |
| 2020-10-07 09:36:04 | → | GyroW_ joins (~GyroW@ptr-48ujrfd1ztq5fjywfw3.18120a2.ip6.access.telenet.be) |
All times are in UTC.