Newest at the top
| 2026-06-23 07:42:14 +0000 | terrorjack | (~terrorjac@2a01:4f8:271:2d98::2) (Quit: The Lounge - https://thelounge.chat) |
| 2026-06-23 07:40:15 +0000 | karenw_ | (~karenw@user/karenw) (Quit: Deep into that darkness peering...) |
| 2026-06-23 07:39:52 +0000 | <lambdabot> | 32768 |
| 2026-06-23 07:39:51 +0000 | <gentauro> | > (length . take maxBound) [0 :: Int16 ..] |
| 2026-06-23 07:37:41 +0000 | <humasect> | ah i miss haskell . |
| 2026-06-23 07:37:25 +0000 | <lambdabot> | *Exception: <<timeout>> |
| 2026-06-23 07:37:18 +0000 | <mauke> | > (length . take maxBound) [0 ..] |
| 2026-06-23 07:34:57 +0000 | <gentauro> | mauke: `length . take maxBound` -> `✲ Name: Infinite: ghc-internal/length` |
| 2026-06-23 07:25:54 +0000 | humasect | (~humasect@dyn-192-249-132-90.nexicom.net) humasect |
| 2026-06-23 07:24:50 +0000 | merijn | (~merijn@2a02:a420:22df:d034:8458:927c:ac6e:3896) merijn |
| 2026-06-23 07:23:44 +0000 | <lambdabot> | [a] -> Int |
| 2026-06-23 07:23:43 +0000 | <mauke> | :t length . take maxBound |
| 2026-06-23 07:23:34 +0000 | tromp | (~textual@2001:1c00:340e:2700:f85c:5d3d:452:a65a) |
| 2026-06-23 07:23:32 +0000 | fp1 | (~Thunderbi@130.233.70.229) fp |
| 2026-06-23 07:21:41 +0000 | <probie> | We're allowed to diverge right, so you're happy with `head xs = case xs of { x:_ -> x; [] -> let x = x in x }` since it's as "total" as `length` |
| 2026-06-23 07:20:31 +0000 | <gentauro> | pattern-matching SHOULD be the way |
| 2026-06-23 07:20:11 +0000 | <gentauro> | probie: tbh, `head` shouldn't even exists in the first place … |
| 2026-06-23 07:19:30 +0000 | <probie> | To clarify, I think it's a silly rule to raise a warning about, but not that much more silly than the one for `head` |
| 2026-06-23 07:16:34 +0000 | tzh | (~tzh@c-76-115-131-146.hsd1.or.comcast.net) (Quit: zzz) |
| 2026-06-23 07:15:50 +0000 | <probie> | If you want to make `length` total, just stick `take n` (for some large n) in front of the list you're calling `length` on |
| 2026-06-23 07:14:07 +0000 | <lambdabot> | (GT,EQ,LT) |
| 2026-06-23 07:14:06 +0000 | <probie> | > let n `compareWithLength` xs = foldr (\x k acc -> if acc <= 0 then LT else k $! (acc - 1)) (\acc -> if acc == 0 then EQ else GT) xs n in (42 `compareWithLength` [1..5], 42 `compareWithLength` [1..42], 42 `compareWithLength` [1..]) |
| 2026-06-23 07:11:36 +0000 | <pavonia> | Right. To me this seems like a too restrictive check |
| 2026-06-23 07:10:13 +0000 | <probie> | (if you still want your code to be total) |
| 2026-06-23 07:10:03 +0000 | chele | (~chele@user/chele) chele |
| 2026-06-23 07:09:59 +0000 | <probie> | What you can't do is compare the length of two lists or treat the length as an Int |
| 2026-06-23 07:09:20 +0000 | <probie> | You can compare an `Int` against the length of a list |
| 2026-06-23 07:08:57 +0000 | <pavonia> | probie: But isn't that just deferring the problem to other functions? If you want to do comparisons with the length of the list you could run into the same issue |
| 2026-06-23 07:06:58 +0000 | merijn | (~merijn@62.45.136.136) (Ping timeout: 276 seconds) |
| 2026-06-23 07:06:34 +0000 | <gentauro> | `length (A l _) = l` 👍 |
| 2026-06-23 07:04:04 +0000 | <gentauro> | hmmm, perhaps that now that I have push access to Hackage. Maybe I should invest time to add my `Data.Array.Log{32|64|128|256}` -> https://blog.stermon.org/articles/2020/05/22/haskell-data-array-log256-safe-idiomatic-and-bottom.h… |
| 2026-06-23 07:03:54 +0000 | <probie> | `data N = Z | S N`, `length = foldr (const S) Z` |
| 2026-06-23 07:03:17 +0000 | <pavonia> | How would you check the length of a list in a productive way then? |
| 2026-06-23 07:01:56 +0000 | merijn | (~merijn@62.45.136.136) merijn |
| 2026-06-23 07:00:59 +0000 | <probie> | I think both are equally valid warnings. `head` is a partial function and `length` is not a productive function |
| 2026-06-23 06:58:57 +0000 | dextaa | (~DV@user/dextaa) (Ping timeout: 271 seconds) |
| 2026-06-23 06:56:36 +0000 | <pavonia> | No idea, tbh. You can't really check whether a list is infinite |
| 2026-06-23 06:55:22 +0000 | <gentauro> | I really appreciate the messages when using `head` as that could make an application crash on empty list (correct way would be doing pattern-matching). But on `length`? What's the alternative to that? |
| 2026-06-23 06:53:23 +0000 | <gentauro> | I'm guessing that (which is correct) that calling `length` on an infinete list could be problematic. But, we don't have dependent types in Haskell right? (Idris comes to mind) |
| 2026-06-23 06:52:39 +0000 | Sgeo | (~Sgeo@user/sgeo) (Read error: Connection reset by peer) |
| 2026-06-23 06:52:36 +0000 | <gentauro> | pavonia: I'm just using `length` on a standard list. |
| 2026-06-23 06:48:09 +0000 | <pavonia> | What is that message even saying? |
| 2026-06-23 06:47:01 +0000 | picnoir | (~picnoir@about/aquilenet/vodoo/NinjaTrappeur) NinjaTrappeur |
| 2026-06-23 06:43:22 +0000 | karenw_ | (~karenw@user/karenw) karenw |
| 2026-06-23 06:38:22 +0000 | jle` | (~jle`@2603:8001:3b00:11:181d:91a8:37ba:ce0c) jle` |
| 2026-06-23 06:35:57 +0000 | merijn | (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 272 seconds) |
| 2026-06-23 06:35:18 +0000 | jle` | (~jle`@23.240.67.73) (Quit: WeeChat 4.8.1) |
| 2026-06-23 06:31:04 +0000 | merijn | (~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn |
| 2026-06-23 06:30:21 +0000 | picnoir | (~picnoir@about/aquilenet/vodoo/NinjaTrappeur) (Ping timeout: 246 seconds) |
| 2026-06-23 06:23:27 +0000 | merijn | (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 261 seconds) |