Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,801,908 events total
2025-12-03 15:10:39 × spew quits (~spew@user/spew) (Quit: nyaa~)
2025-12-03 15:10:44 <__monty__> This is the missing case analysis I was referring to.
2025-12-03 15:10:56 spew joins (~spew@user/spew)
2025-12-03 15:10:56 <kuribas`> > foldr (\(x:xs) cont s -> if (s > 7) then (x:xs) else (x*2) : cont (s+x)) (const []) (tails [1..10]) 0
2025-12-03 15:11:00 <__monty__> But the idea works.
2025-12-03 15:11:00 <lambdabot> [2,4,6,8,5,6,7,8,9,10]
2025-12-03 15:12:22 califax_ joins (~califax@user/califx)
2025-12-03 15:13:49 chexum_ joins (~quassel@gateway/tor-sasl/chexum)
2025-12-03 15:14:06 × chexum quits (~quassel@gateway/tor-sasl/chexum) (Ping timeout: 272 seconds)
2025-12-03 15:14:06 × califax quits (~califax@user/califx) (Ping timeout: 272 seconds)
2025-12-03 15:14:06 × sord937 quits (~sord937@gateway/tor-sasl/sord937) (Ping timeout: 272 seconds)
2025-12-03 15:14:07 califax_ is now known as califax
2025-12-03 15:15:02 <lucabtz> kuribas` if there is no state can't you just use break
2025-12-03 15:15:15 <kuribas`> break?
2025-12-03 15:15:27 sord937 joins (~sord937@gateway/tor-sasl/sord937)
2025-12-03 15:15:40 <lucabtz> or span
2025-12-03 15:15:59 <kuribas`> sure
2025-12-03 15:16:26 × bitdex_ quits (~bitdex@gateway/tor-sasl/bitdex) (Quit: = "")
2025-12-03 15:16:43 <kuribas`> > let (xs, ys) = break (> 5) [1..10] in map (*2) xs ++ ys
2025-12-03 15:16:46 <lambdabot> [2,4,6,8,10,6,7,8,9,10]
2025-12-03 15:16:54 <lucabtz> yep
2025-12-03 15:21:12 aljazmc joins (~aljazmc@user/aljazmc)
2025-12-03 15:22:30 × st_aldini quits (~Thunderbi@2605:a601:a07c:7400:6e26:f360:f11d:472c) (Quit: st_aldini)
2025-12-03 15:22:58 st_aldini joins (~Thunderbi@2605:a601:a07c:7400:6e26:f360:f11d:472c)
2025-12-03 15:26:09 × akegalj quits (~akegalj@141-138-27-206.dsl.iskon.hr) (Quit: leaving)
2025-12-03 15:27:23 <__monty__> Yes, already mentioned that.
2025-12-03 15:27:51 <kuribas`> > foldr (\(x:xs) xs2 -> if False then (x:xs) else (x*2) : xs2) [] (init $ tails [1..10]) -- __monty__
2025-12-03 15:27:54 <lambdabot> [2,4,6,8,10,12,14,16,18,20]
2025-12-03 15:28:37 × merijn quits (~merijn@77.242.116.146) (Ping timeout: 265 seconds)
2025-12-03 15:29:14 × Square2 quits (~Square4@user/square) (Ping timeout: 260 seconds)
2025-12-03 15:30:47 Googulator88 joins (~Googulato@2a01-036d-0106-479c-d9ec-010d-f188-ffcb.pool6.digikabel.hu)
2025-12-03 15:31:10 <__monty__> Yeah, that works.
2025-12-03 15:32:44 <__monty__> "Foldr the init of the tails" is not quite the elegance I was hoping for but it does make foldr more useful still.
2025-12-03 15:33:02 merijn joins (~merijn@77.242.116.146)
2025-12-03 15:33:59 × Googulator40 quits (~Googulato@2a01-036d-0106-479c-d9ec-010d-f188-ffcb.pool6.digikabel.hu) (Ping timeout: 250 seconds)
2025-12-03 15:35:51 <kuribas`> :t tails1
2025-12-03 15:35:54 <lambdabot> error: [GHC-88464]
2025-12-03 15:35:54 <lambdabot> Variable not in scope: tails1
2025-12-03 15:35:54 <lambdabot> Suggested fix:
2025-12-03 15:38:06 <kuribas`> https://hackage.haskell.org/package/base-4.21.0.0/docs/Data-List.html#v:tails1
2025-12-03 15:39:54 × tromp quits (~textual@2001:1c00:3487:1b00:a4ed:9e46:fd5d:6b4e) (Quit: My iMac has gone to sleep. ZZZzzz…)
2025-12-03 15:40:02 <kuribas`> removed apparently...
2025-12-03 15:41:05 <__monty__> Probably because it's partial?
2025-12-03 15:41:18 <__monty__> Oh, it's not.
2025-12-03 15:44:30 <kuribas`> ah no, it's added
2025-12-03 15:44:33 lambda_gibbon joins (~lambda_gi@208.83.175.39)
2025-12-03 15:45:34 <kuribas`> __monty__: tbf if you really care about performance, you shouldn't use linked lists.
2025-12-03 15:46:53 <__monty__> I wasn't really asking about lists though. More like anything Foldable or Somethingable if folds are not a powerful enough concept to capture the behavior.
2025-12-03 15:48:12 <Leary> `Witherable`, probably.
2025-12-03 15:49:33 <Leary> Well, if you want to drop any elements. Maybe `Traversable` is enough if you don't.
2025-12-03 15:49:57 × merijn quits (~merijn@77.242.116.146) (Ping timeout: 250 seconds)
2025-12-03 15:50:26 <__monty__> I'm open to suggestions for a data structure for the specific case of pushing a value into the flat structure from the front and stopping when the value being pushed is smaller than the next. Think of a row of marbles, the first marble smaller than the one pushing against it falls out.
2025-12-03 15:50:30 <kuribas`> __monty__: folds are isomorphic to a list
2025-12-03 15:50:38 <kuribas`> :t toList
2025-12-03 15:50:41 <lambdabot> Foldable t => t a -> [a]
2025-12-03 15:51:37 <Leary> __monty__: In that case, why flat? It really sounds like you want a heap or a set.
2025-12-03 15:52:16 × Jackneill quits (~Jackneill@178-164-177-218.pool.digikabel.hu) (Read error: Connection reset by peer)
2025-12-03 15:52:21 <__monty__> In my case the extra structure isn't necessary.
2025-12-03 15:52:28 Jackneill joins (~Jackneill@178-164-177-218.pool.digikabel.hu)
2025-12-03 15:55:13 divlamir joins (~divlamir@user/divlamir)
2025-12-03 15:56:04 merijn joins (~merijn@77.242.116.146)
2025-12-03 15:56:08 × pavonia quits (~user@user/siracusa) (Quit: Bye!)
2025-12-03 15:58:18 × acidjnk quits (~acidjnk@p200300d6e71719231986af8ebf40e0fc.dip0.t-ipconnect.de) (Ping timeout: 244 seconds)
2025-12-03 16:02:28 × divlamir quits (~divlamir@user/divlamir) (Ping timeout: 255 seconds)
2025-12-03 16:02:51 tromp joins (~textual@2001:1c00:3487:1b00:a4ed:9e46:fd5d:6b4e)
2025-12-03 16:04:39 <tomsmeding> __monty__: if the values have a well-defined ordering, a binary tree will give you O(log(n)) insertion instead of O(n)
2025-12-03 16:04:43 × trickard quits (~trickard@cpe-85-98-47-163.wireline.com.au) (Ping timeout: 255 seconds)
2025-12-03 16:04:56 <tomsmeding> but the fact that you're asking about a list suggests you have no such ordering :)
2025-12-03 16:05:43 divlamir joins (~divlamir@user/divlamir)
2025-12-03 16:05:45 Googulator56 joins (~Googulato@2a01-036d-0106-479c-d9ec-010d-f188-ffcb.pool6.digikabel.hu)
2025-12-03 16:05:47 × Googulator88 quits (~Googulato@2a01-036d-0106-479c-d9ec-010d-f188-ffcb.pool6.digikabel.hu) (Quit: Client closed)
2025-12-03 16:06:01 <tomsmeding> (that data structure is Data.Set)
2025-12-03 16:16:21 trickard_ joins (~trickard@cpe-85-98-47-163.wireline.com.au)
2025-12-03 16:17:58 Lycurgus joins (~juan@user/Lycurgus)
2025-12-03 16:25:15 acidjnk joins (~acidjnk@p200300d6e71719231986af8ebf40e0fc.dip0.t-ipconnect.de)
2025-12-03 16:28:55 × gawen quits (~gawen@user/gawen) (Quit: cya)
2025-12-03 16:30:19 <tomsmeding> can I override GHC's arity analysis to force a particular function to have lower arity than GHC would otherwise infer?
2025-12-03 16:30:50 <tomsmeding> I have some data that I can already compute based on only the first argument that I would like to share over multiple calls that have the same first argument, and GHC isn't doing it
2025-12-03 16:31:20 <Lycurgus> wo TH or nuthin i presume
2025-12-03 16:31:22 <tomsmeding> I can force GHC to do what I want by making the "inner function" NOINLINE (at which point the (inlined) "outer function" does the proper sharing), but that feels like a hack
2025-12-03 16:32:33 <tomsmeding> (I don't see how TH is relevant here)
2025-12-03 16:32:45 <Lycurgus> nor "nuthin"?
2025-12-03 16:32:55 <tomsmeding> well, presumably something is relevant here, yes
2025-12-03 16:33:28 gawen joins (~gawen@user/gawen)
2025-12-03 16:33:37 <Lycurgus> i couild expand as a very rude name of this category of quety has occured to me but being a real person i know better
2025-12-03 16:34:05 <Leary> tomsmeding: Does it work if you push the latter args into lambdas and bang the shared binding?
2025-12-03 16:34:29 × aljazmc quits (~aljazmc@user/aljazmc) (Remote host closed the connection)
2025-12-03 16:34:35 <Lycurgus> *query
2025-12-03 16:34:56 aljazmc joins (~aljazmc@user/aljazmc)
2025-12-03 16:34:58 <Lycurgus> *could
2025-12-03 16:35:27 <tomsmeding> Leary: doesn't seem to; they were already in a separate lambda (within a 'let' that defines the shared binding), but adding a ! doesn't seem to help
2025-12-03 16:35:50 haritz joins (~hrtz@2a01:4b00:bc2e:7000:d5af:a266:ca31:5ef8)
2025-12-03 16:35:50 × haritz quits (~hrtz@2a01:4b00:bc2e:7000:d5af:a266:ca31:5ef8) (Changing host)
2025-12-03 16:35:50 haritz joins (~hrtz@user/haritz)
2025-12-03 16:35:53 <Leary> `NOINLINE` it is, then.
2025-12-03 16:36:33 <tomsmeding> the downside is that that makes performance slightly worse if the function is only called once
2025-12-03 16:36:45 <tomsmeding> but I'll just have to live with that I suppose :)
2025-12-03 16:37:06 <tomsmeding> (it's a 2x improvement when called many times, at the cost of a 10% slowdown when called once)
2025-12-03 16:37:32 <Leary> Oh, you're putting that on the inner /function/? Why not on the shared value?
2025-12-03 16:37:50 <tomsmeding> how do you suggest I put it on the shared value?

All times are in UTC.