Logs: freenode/#haskell
| 2020-11-19 11:39:19 | <dminuoso> | It's how the function we replace the cons with associates |
| 2020-11-19 11:39:39 | <boxscape> | dminuoso I know, but for that you need to have some mental image of what left and right means in a list, right? |
| 2020-11-19 11:39:58 | <boxscape> | which isn't fundamentally part of the type |
| 2020-11-19 11:40:16 | <kuribas> | (a <> (b <> (c <> d))) should be the same as (((a <> b) <> c) <> d) |
| 2020-11-19 11:40:25 | <kuribas> | but one may be more efficient to calculate |
| 2020-11-19 11:40:34 | <boxscape> | so if you swap directions of that mental image, you rename foldr to foldl and foldl to foldr, and perhaps write the constructor as [a] : a, and I imagine that's what a snoc list would be |
| 2020-11-19 11:40:38 | <boxscape> | functionally the same as a list |
| 2020-11-19 11:40:55 | <dminuoso> | Ill await nshepperd's response. :) |
| 2020-11-19 11:40:59 | <dminuoso> | To clarify |
| 2020-11-19 11:40:59 | <boxscape> | that's fair |
| 2020-11-19 11:41:00 | <kuribas> | > foldMap' (<>) [a, b, c, d] |
| 2020-11-19 11:41:02 | <lambdabot> | <Expr -> Expr> |
| 2020-11-19 11:41:24 | <kuribas> | > foldMap' Sum [a, b, c, d] |
| 2020-11-19 11:41:26 | <lambdabot> | Sum {getSum = 0 + a + b + c + d} |
| 2020-11-19 11:41:30 | <kuribas> | > foldMap Sum [a, b, c, d] |
| 2020-11-19 11:41:32 | <lambdabot> | Sum {getSum = a + (b + (c + (d + 0)))} |
| 2020-11-19 11:41:51 | <dminuoso> | kuribas: The difference matters in two respects: Is the input data structure infinite, and do we need to be lazy on the output (do we build a chain of data constructors) |
| 2020-11-19 11:42:18 | <kuribas> | those aren't the same value |
| 2020-11-19 11:42:24 | <kuribas> | are they? |
| 2020-11-19 11:42:24 | × | chaosmasttter quits (~chaosmast@p200300c4a70b2a01441f1455f36b3658.dip0.t-ipconnect.de) (Ping timeout: 240 seconds) |
| 2020-11-19 11:42:59 | <kuribas> | ah they are since 0 is the empty element |
| 2020-11-19 11:43:16 | × | invaser quits (~Thunderbi@31.148.23.125) (Ping timeout: 240 seconds) |
| 2020-11-19 11:43:20 | <dminuoso> | kuribas: by monoid laws they are the same |
| 2020-11-19 11:43:41 | <dminuoso> | because precisely, a monoid is associative (so it doesnt matter how they associate) and mempty is the identity element (it doesnt matter where you slap it onto) |
| 2020-11-19 11:44:15 | → | ft joins (~ft@shell.chaostreff-dortmund.de) |
| 2020-11-19 11:44:47 | <dminuoso> | Guess that's the sort of things that makes foldMap so cool. You can just replace it with foldMap' without worrying whether it changes its meaning |
| 2020-11-19 11:44:55 | <dminuoso> | with foldr/foldl |
| 2020-11-19 11:45:07 | <dminuoso> | you have to manually check for associativity and identity |
| 2020-11-19 11:46:55 | × | zyklotomic quits (~ethan@unaffiliated/chocopuff) (Quit: WeeChat 2.9) |
| 2020-11-19 11:46:58 | → | Alleria_ joins (~AllahuAkb@2604:2000:1484:26:ef:21ba:eb1b:b066) |
| 2020-11-19 11:47:05 | <boxscape> | hmm I wonder if a monoid with separate left and right identity elements could be useful |
| 2020-11-19 11:47:31 | <tomjaguarpaw> | If you had left and right identities el and er what would el <> er be? |
| 2020-11-19 11:48:26 | × | Stanley00 quits (~stanley00@unaffiliated/stanley00) () |
| 2020-11-19 11:48:53 | <boxscape> | that's a very good question |
| 2020-11-19 11:49:17 | <boxscape> | I guess it wouldn't be useful then |
| 2020-11-19 11:49:36 | × | cfricke quits (~cfricke@unaffiliated/cfricke) (Quit: WeeChat 2.9) |
| 2020-11-19 11:49:53 | × | Amras quits (~Amras@unaffiliated/amras0000) (Ping timeout: 272 seconds) |
| 2020-11-19 11:50:32 | <kuribas> | dminuoso: it does change meaning wrt bottom |
| 2020-11-19 11:50:35 | → | jeet1 joins (~jeet@183.83.41.219) |
| 2020-11-19 11:50:48 | <boxscape> | Although, I guess you could have a (not-quite-)monoid that *only* has left identity (or only right-identity) |
| 2020-11-19 11:51:22 | <kuribas> | > foldMap First [1, 2, undefined] |
| 2020-11-19 11:51:24 | <lambdabot> | error: |
| 2020-11-19 11:51:24 | <lambdabot> | • No instance for (Num (Maybe ())) arising from a use of ‘e_112’ |
| 2020-11-19 11:51:24 | <lambdabot> | • In the expression: e_112 |
| 2020-11-19 11:51:50 | <nshepperd> | yeah a snoc list is just a cons list that has had left and right renamed |
| 2020-11-19 11:52:41 | × | cosimone quits (~cosimone@2001:b07:ae5:db26:d849:743b:370b:b3cd) (Remote host closed the connection) |
| 2020-11-19 11:53:02 | → | cosimone joins (~cosimone@2001:b07:ae5:db26:d849:743b:370b:b3cd) |
| 2020-11-19 11:53:04 | <kuribas> | > foldMap First [Just 1, Just 2, undefined] |
| 2020-11-19 11:53:06 | <lambdabot> | First {getFirst = Just 1} |
| 2020-11-19 11:53:12 | <kuribas> | > foldMap' First [Just 1, Just 2, undefined] |
| 2020-11-19 11:53:14 | <lambdabot> | First {getFirst = Just 1} |
| 2020-11-19 11:53:47 | × | noctux quits (~noctux@unaffiliated/noctux) (Read error: Connection reset by peer) |
| 2020-11-19 11:53:48 | <nshepperd> | you won't often find them in the wild |
| 2020-11-19 11:54:25 | → | noctux joins (~noctux@unaffiliated/noctux) |
| 2020-11-19 11:54:36 | <kuribas> | > foldMap All [True, False, undefined] |
| 2020-11-19 11:54:37 | <lambdabot> | All {getAll = False} |
| 2020-11-19 11:54:41 | <kuribas> | > foldMap' All [True, False, undefined] |
| 2020-11-19 11:54:42 | <lambdabot> | All {getAll = False} |
| 2020-11-19 11:54:49 | <kuribas> | hmmm |
| 2020-11-19 11:55:10 | → | m0rphism joins (~m0rphism@HSI-KBW-095-208-098-207.hsi5.kabel-badenwuerttemberg.de) |
| 2020-11-19 11:55:36 | <dminuoso> | nshepperd: That sounds.. like a list. |
| 2020-11-19 11:56:04 | <nshepperd> | well yeah |
| 2020-11-19 11:56:38 | <nshepperd> | you can just do things with lists, and remember to reverse things in your head when reading code |
| 2020-11-19 11:57:27 | × | agrajag` quits (~agrajag`@84.39.117.57) (Remote host closed the connection) |
| 2020-11-19 11:57:31 | <nshepperd> | but sometimes it's easier to have a different type so that the syntax corresponds to the intended ordering |
| 2020-11-19 11:57:56 | <dminuoso> | So roughly a `data Tsil a = Snoc a (Tsil a) | Lin` differs from [] by conceptually reversing before folding/traversing? |
| 2020-11-19 11:58:15 | <dminuoso> | (or in case of traverse, revere, traverse, and then reverse again) |
| 2020-11-19 11:58:15 | <kuribas> | they are the same even with bottom then? |
| 2020-11-19 11:59:14 | <boxscape> | the list matches the intended left right order better with Snoc (Tsil a) a: Lin `SNoc` 3 `Snoc` 2 `Snoc` 1 |
| 2020-11-19 11:59:17 | <nshepperd> | generally you write SnocList a = Nil | Snoc (SnocList a) a |
| 2020-11-19 11:59:29 | → | chaosmasttter joins (~chaosmast@p200300c4a70b2a01441f1455f36b3658.dip0.t-ipconnect.de) |
| 2020-11-19 11:59:48 | <dminuoso> | Why not just use Dual? |
| 2020-11-19 12:00:02 | × | jeet1 quits (~jeet@183.83.41.219) (Quit: WeeChat 2.9) |
| 2020-11-19 12:00:11 | <nshepperd> | performance |
| 2020-11-19 12:00:23 | <dminuoso> | Mmm, fair |
| 2020-11-19 12:00:34 | <nshepperd> | also, pattern matching |
| 2020-11-19 12:00:44 | × | Lycurgus quits (~niemand@cpe-45-46-142-188.buffalo.res.rr.com) (Quit: Exeunt) |
| 2020-11-19 12:00:45 | → | cfricke joins (~cfricke@unaffiliated/cfricke) |
| 2020-11-19 12:00:46 | × | pfurla quits (~pfurla@190.15.195.173.client.static.strong-in52.as13926.net) (Ping timeout: 272 seconds) |
| 2020-11-19 12:00:56 | <dminuoso> | boxscape: Ill take a look at your gist later tonight, think I need to sit down and employ the good ol' fashioned Feynman algorithm |
| 2020-11-19 12:00:57 | → | __monty__ joins (~toonn@unaffiliated/toonn) |
| 2020-11-19 12:01:18 | <dminuoso> | nshepperd: well, the pattern matching is a mood argument, since it's no different from (:) |
| 2020-11-19 12:01:37 | → | pfurla joins (~pfurla@ool-182ed2e2.dyn.optonline.net) |
| 2020-11-19 12:01:44 | <nshepperd> | nooo |
| 2020-11-19 12:01:58 | <dminuoso> | Whether you write `1:2:3:[]` or `[]:%3:%2:%1` seems no different at all |
| 2020-11-19 12:02:07 | <nshepperd> | i mean, you can't use Dual when you're doing type level lists |
| 2020-11-19 12:02:07 | × | AWizzArd quits (~code@unaffiliated/awizzard) (Read error: Connection reset by peer) |
| 2020-11-19 12:02:10 | <dminuoso> | ah |
| 2020-11-19 12:02:41 | → | AWizzArd joins (~code@gehrels.uberspace.de) |
| 2020-11-19 12:03:42 | <boxscape> | dminuoso In a way I think these proofs are even harder to understand in Haskell than in some other languages, because the way constraint resolution makes it so it's not obvious how things are actually plugged together (though at least these are small proofs). But replacing the rhss with typed holes should help. |
| 2020-11-19 12:03:44 | × | xff0x quits (~fox@2001:1a81:534b:a000:20f1:4040:a0e2:f16) (Ping timeout: 240 seconds) |
| 2020-11-19 12:03:58 | <boxscape> | s/the way// |
| 2020-11-19 12:04:32 | <kuribas> | I find myself going back from typed holes to tuples |
| 2020-11-19 12:04:45 | → | xff0x joins (~fox@2001:1a81:534b:a000:65df:cebc:ef3d:70f7) |
| 2020-11-19 12:04:48 | <kuribas> | the error message is much better |
| 2020-11-19 12:05:06 | <__monty__> | Do you mean unit? |
| 2020-11-19 12:05:13 | <kuribas> | __monty__: yes |
| 2020-11-19 12:05:36 | <kuribas> | my-fun = () $ partial-implementation |
| 2020-11-19 12:06:11 | <__monty__> | That does change how associativity is parsed, no? |
| 2020-11-19 12:06:42 | <boxscape> | oh huh |
All times are in UTC.