Newest at the top
| 2026-03-09 10:20:12 +0100 | <lambdabot> | Ord a1 => (a2, a1) -> (a2, a1) -> Ordering |
| 2026-03-09 10:20:11 +0100 | <merijn> | :t comparing snd |
| 2026-03-09 10:20:07 +0100 | <lambdabot> | Ord a => (a, b) -> (a, b) -> Ordering |
| 2026-03-09 10:20:06 +0100 | <merijn> | :t comparing fst |
| 2026-03-09 10:19:36 +0100 | <merijn> | castan: But that instance applies recursively (i.e. since "a -> b" is a Monoid when 'b' is, then "c -> a -> b" (which is just "c -> (a -> b)" is also a monoid) |
| 2026-03-09 10:18:48 +0100 | <merijn> | castan: "instance Monoid b => Monoid (a -> b) where mappend f g = \x -> mappend (f x) (g x)" |
| 2026-03-09 10:18:25 +0100 | fp | (~Thunderbi@2001:708:20:1406::1370) fp |
| 2026-03-09 10:18:08 +0100 | <merijn> | castan: Basically the monoid on functions is "if the final result is a monoid, then simply pass each argument to both functions and mappend the result" |
| 2026-03-09 10:18:04 +0100 | fp | (~Thunderbi@staff235.kora-dyn.aalto.fi) (Client Quit) |
| 2026-03-09 10:17:37 +0100 | fp | (~Thunderbi@staff235.kora-dyn.aalto.fi) fp |
| 2026-03-09 10:17:24 +0100 | <merijn> | Even funkier with newtypes like Down :p |
| 2026-03-09 10:17:19 +0100 | <lambdabot> | [(3,1),(2,1),(1,1),(3,9),(2,9),(1,9)] |
| 2026-03-09 10:17:17 +0100 | <merijn> | > sortBy (comparing snd <> comparing (Down . fst)) [(3,9), (2,9), (1, 9), (3, 1), (2, 1), (1,1)] |
| 2026-03-09 10:16:49 +0100 | <merijn> | It's slow as sin |
| 2026-03-09 10:16:46 +0100 | <merijn> | Holy moly is Hackage being DOSed or something? |
| 2026-03-09 10:15:55 +0100 | <castan> | that's wild, I need to play with it for a bit to understand how |
| 2026-03-09 10:15:18 +0100 | <lambdabot> | [(2,1),(1,1),(3,1),(2,9),(1,9),(3,9)] |
| 2026-03-09 10:15:17 +0100 | <probie> | > sortBy (comparing snd <> comparing (flip mod 2 . fst) <> comparing fst) [(3,9), (2,9), (1, 9), (3, 1), (2, 1), (1,1)] |
| 2026-03-09 10:14:12 +0100 | <merijn> | Magic |
| 2026-03-09 10:14:02 +0100 | <lambdabot> | [(1,1),(2,1),(3,1),(1,9),(2,9),(3,9)] |
| 2026-03-09 10:14:00 +0100 | <merijn> | > sortBy (comparing snd <> comparing fst) [(3,9), (2,9), (1, 9), (3, 1), (2, 1), (1,1)] |
| 2026-03-09 10:13:14 +0100 | <lambdabot> | (a -> a -> Ordering) -> [a] -> [a] |
| 2026-03-09 10:13:13 +0100 | <merijn> | :t sortBy |
| 2026-03-09 10:13:08 +0100 | <lambdabot> | Ord a => (b -> a) -> b -> b -> Ordering |
| 2026-03-09 10:13:07 +0100 | <merijn> | :t comparing |
| 2026-03-09 10:12:02 +0100 | <merijn> | castan: And absolutely brilliant use for this monoid is the fact that Ordering is a monoid, so you can use it to combine comparison functions to do multi way ordering |
| 2026-03-09 10:10:58 +0100 | <merijn> | __monty__: Which, if you don't realise the monoid on functions is confusing |
| 2026-03-09 10:10:40 +0100 | <merijn> | __monty__: No, his question is why is it correct at all :p |
| 2026-03-09 10:10:20 +0100 | <merijn> | best monoit instance ever |
| 2026-03-09 10:10:19 +0100 | <__monty__> | Were you expecting a different result? Because `mappend mempty (Sum 3) = Sum 3` too. |
| 2026-03-09 10:08:22 +0100 | <lambdabot> | Num t => Sum t |
| 2026-03-09 10:08:21 +0100 | <mesaoptimizer> | :t mappend mempty Sum 3 |
| 2026-03-09 10:08:15 +0100 | <lambdabot> | Num a => a -> Sum a |
| 2026-03-09 10:08:14 +0100 | <mesaoptimizer> | :t mappend mempty Sum |
| 2026-03-09 10:08:07 +0100 | <lambdabot> | Monoid a => a -> a |
| 2026-03-09 10:08:06 +0100 | <mesaoptimizer> | :t mappend mempty |
| 2026-03-09 10:07:59 +0100 | <lambdabot> | Monoid a => a -> a -> a |
| 2026-03-09 10:07:58 +0100 | <mesaoptimizer> | :t mappend |
| 2026-03-09 10:06:35 +0100 | <castan> | I see now, thank you |
| 2026-03-09 10:05:42 +0100 | <castan> | Oh hahahha |
| 2026-03-09 10:05:39 +0100 | <lambdabot> | Monoid a => a -> a |
| 2026-03-09 10:05:38 +0100 | <probie> | :t (mappend mempty) |
| 2026-03-09 10:05:22 +0100 | <lambdabot> | Num a => a -> Sum a |
| 2026-03-09 10:05:21 +0100 | <probie> | :t mappend mempty Sum |
| 2026-03-09 10:05:04 +0100 | <Leary> | One key detail here being `Monoid b => Monoid (a -> b)`. |
| 2026-03-09 10:04:42 +0100 | <Leary> | castan: It doesn't get /parsed/ as that; that's what it equals. `mappend mempty x = x` ==> `mappend mempty Sum = Sum` ==> `mappend mempty Sum 3 = Sum 3`. |
| 2026-03-09 10:04:35 +0100 | <probie> | None |
| 2026-03-09 10:03:08 +0100 | loungerry_ | (~loungerry@150.241.86.78) (Remote host closed the connection) |
| 2026-03-09 10:02:24 +0100 | czan | (~czan@user/mange) czan |
| 2026-03-09 10:01:50 +0100 | <castan> | Hi. Can someone help me understand what sorcery makes `mappend mempty Sum 3` get parsed as `mappend mempty (Sum 3)` |