Logs: liberachat/#haskell
| 2026-02-24 21:15:33 | <dolio> | I think you can directly put a builder, too. |
| 2026-02-24 21:15:35 | <EvanR> | a lazy text itself is already a lazy list |
| 2026-02-24 21:15:35 | <tomsmeding> | or, well, it does, but then it (kind of) synchronises with the one in the RTS so they kinda merge |
| 2026-02-24 21:15:46 | <EvanR> | then a builder to make a straight lazy list is not helping |
| 2026-02-24 21:16:31 | <tomsmeding> | dolio: doesn't seem like you can, but toLazyText should be fine |
| 2026-02-24 21:16:39 | × | merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 255 seconds) |
| 2026-02-24 21:16:49 | <EvanR> | builder is often recommended in case people are trying to form a big sequence from pieces other than just tacking onto the end |
| 2026-02-24 21:16:54 | <dolio> | Oh. I guess it's just bytestring builders. |
| 2026-02-24 21:17:10 | <tomsmeding> | EvanR: which i why I recommended `T.intercalate` first |
| 2026-02-24 21:17:20 | <tomsmeding> | but that doesn't have the nice Int serialiser |
| 2026-02-24 21:17:41 | <newmind> | lantti: what's the actual time you're getting? just to see how reasonable it is |
| 2026-02-24 21:18:02 | → | aka_dude joins (~aka_dude@2a03:f80:30:f490::1) |
| 2026-02-24 21:18:19 | × | morj_away quits (~morj@user/morj) (Quit: Konversation terminated!) |
| 2026-02-24 21:19:01 | × | aka_dude quits (~aka_dude@2a03:f80:30:f490::1) (Remote host closed the connection) |
| 2026-02-24 21:19:21 | <tomsmeding> | further tip: benchmark your code but setting `ints = replicate 100000 123456789` or something, just to double-check it's actually the printing that's slow, not the computation preceding it |
| 2026-02-24 21:20:01 | <newmind> | that was my second suggestion, replacing ints with [1..100000] or something |
| 2026-02-24 21:20:32 | <EvanR> | .oO( replace the printing with just evaluating the ints in sequence ) |
| 2026-02-24 21:20:42 | <tomsmeding> | that's the dual version :p |
| 2026-02-24 21:23:22 | <mauke> | :t mapM_ evaluate |
| 2026-02-24 21:23:24 | <lambdabot> | Foldable t => t b -> IO () |
| 2026-02-24 21:24:47 | <EvanR> | hopefully evaluate doesn't first take an MVar before evaluating xD |
| 2026-02-24 21:25:04 | <EvanR> | requiring us to do artifically additional buffering wtf |
| 2026-02-24 21:25:35 | <lantti> | I can't figure out the profiling under stack right now, but unix time command for the 10000000 Ints case gives 0.8s |
| 2026-02-24 21:25:39 | × | cbarrett quits (sid192934@id-192934.helmsley.irccloud.com) (Server closed connection) |
| 2026-02-24 21:25:51 | → | cbarrett joins (sid192934@id-192934.helmsley.irccloud.com) |
| 2026-02-24 21:25:54 | <EvanR> | 10^7 ints |
| 2026-02-24 21:26:07 | <lantti> | oops, 1000000 |
| 2026-02-24 21:26:32 | <EvanR> | are they particularly uniform ints or like up to 3 digits or |
| 2026-02-24 21:27:17 | <lantti> | the whole task is that one: https://cses.fi/alon/task/1092/ |
| 2026-02-24 21:27:55 | <lantti> | so basically two runs of consecutive ints with one exception |
| 2026-02-24 21:28:09 | <lantti> | in each run |
| 2026-02-24 21:29:33 | <EvanR> | ok it doesn't seem to be trying to print out literally 10^6 ints but the program is more complex than that |
| 2026-02-24 21:30:17 | → | merijn joins (~merijn@host-cl.cgnat-g.v4.dfn.nl) |
| 2026-02-24 21:30:24 | <haskellbridge> | <ijouw> Is there a good way to define a more general Ord class that avoids troubles with functions using Ordered argumens like nubOn? |
| 2026-02-24 21:31:02 | <EvanR> | :t nubOn |
| 2026-02-24 21:31:20 | <EvanR> | @botsnack |
| 2026-02-24 21:31:31 | <lambdabot> | :) |
| 2026-02-24 21:31:32 | <lambdabot> | error: [GHC-88464] Variable not in scope: nubOn |
| 2026-02-24 21:31:52 | → | aka_dude joins (~aka_dude@192.71.166.120) |
| 2026-02-24 21:32:26 | <haskellbridge> | <ijouw> i meant this: nubOrdOn :: Ord b => (a -> b) -> [a] -> [a] |
| 2026-02-24 21:32:29 | × | jreicher quits (~joelr@user/jreicher) (Ping timeout: 252 seconds) |
| 2026-02-24 21:32:40 | <EvanR> | what is the trouble? |
| 2026-02-24 21:32:41 | <haskellbridge> | <ijouw> Filters duplicates by sorting |
| 2026-02-24 21:32:50 | <lantti> | It does need to print out 10^6 ints in the case n = 10^6. But thanks for the tips, i'll try some out and see if that makes a difference. |
| 2026-02-24 21:33:09 | → | jreicher joins (~joelr@user/jreicher) |
| 2026-02-24 21:33:46 | <EvanR> | yeah but it has to print a lot more than that in that case, so someone trying to replicate your running time is going to undershoot by a lot |
| 2026-02-24 21:34:07 | <tomsmeding> | EvanR: yes, "YES" and 2 more ints |
| 2026-02-24 21:34:07 | <haskellbridge> | <ijouw> It obviously does not work on MyOrd a => [a], and specifying MyOrd a, Ord a => [a] makes MyOrd seem pointless |
| 2026-02-24 21:34:21 | <EvanR> | oh it's only 2 lines |
| 2026-02-24 21:34:25 | <EvanR> | not N |
| 2026-02-24 21:34:57 | <EvanR> | MyOrd ? |
| 2026-02-24 21:35:02 | × | merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 268 seconds) |
| 2026-02-24 21:35:11 | <EvanR> | you want it to work on a variable class? |
| 2026-02-24 21:35:41 | <EvanR> | if you're trying to define an alternate Ord instance, that's what newtypes are for, then you use Ord |
| 2026-02-24 21:36:26 | <haskellbridge> | <ijouw> I want to use type families to allow the return type to be wrapped for DSL stuff |
| 2026-02-24 21:36:58 | <tomsmeding> | it kind of sounds like you'll need to be a bit more specific here |
| 2026-02-24 21:37:42 | <EvanR> | maybe you need ways to lift library functions like nubOrdOn into your DSL |
| 2026-02-24 21:43:02 | → | Arsen joins (16abab341f@gentoo/developer/managarm.dev.Arsen) |
| 2026-02-24 21:45:40 | → | merijn joins (~merijn@host-cl.cgnat-g.v4.dfn.nl) |
| 2026-02-24 21:45:47 | <haskellbridge> | <ijouw> I want this https://hackage-content.haskell.org/package/Boolean-0.2.4/docs/Data-Boolean.html#t:OrdB and then define a function nubOrd' :: (OrdB a, BooleanOf a ~ Bool) => [a] -> [a] ; (maybe i should just not reimplement everything...) |
| 2026-02-24 21:46:06 | <monochrom> | I am unconvinced that (putStrLn . unwords . map show) is too slow. It's only 0.05 seconds on my laptop if you redirect to a file (which is the right thing to do if you're simulating an online autotester; if you let it go to a terminal, then the bottleneck is the terminal) |
| 2026-02-24 21:47:07 | <newmind> | .o( but it does say a lot about haskell as a language/ecosystem that we're discussing it ) |
| 2026-02-24 21:47:33 | <EvanR> | it? |
| 2026-02-24 21:47:58 | <newmind> | why something as simple as "print out this list of numbers" might be slow |
| 2026-02-24 21:48:16 | <monochrom> | No, it says a lot about people having double standards. |
| 2026-02-24 21:48:19 | → | Guest81 joins (~Guest81@52.144.37.132) |
| 2026-02-24 21:48:20 | <EvanR> | people mistake what's slow all the time, that's a haskell thing |
| 2026-02-24 21:49:28 | <EvanR> | this problem that separates a million integers into two sets that adds up to the same thing |
| 2026-02-24 21:49:28 | <newmind> | ywah, but with lazy eval, monads that need to be resolved... it's less straightforward than it would be in C.. which is perfectly fine, just... weird |
| 2026-02-24 21:49:38 | <EvanR> | printing it out doesn't sound like the crunchy part |
| 2026-02-24 21:50:10 | <mauke> | printing is slow in C, too |
| 2026-02-24 21:50:15 | <monochrom> | After compiling with -O, the IO monad doesn't exist in the machine code. |
| 2026-02-24 21:50:21 | × | merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 265 seconds) |
| 2026-02-24 21:50:28 | <EvanR> | i was going to say C is the one where you are sometimes trying to deduce how slow printing is |
| 2026-02-24 21:50:29 | <tomsmeding> | (that's a claim) |
| 2026-02-24 21:50:36 | <tomsmeding> | maybe in this tight loop that's true |
| 2026-02-24 21:50:44 | <mauke> | back when I did SPOJ, I got significant time improvements by bypassing stdio |
| 2026-02-24 21:50:48 | <lantti> | I suspected the printing because I realized there is an analytic solution to the actual problem and generating the lists is just some math operations and [1..xyz] |
| 2026-02-24 21:51:08 | <lantti> | I'm in the process of re-evaluating that assumption :) |
| 2026-02-24 21:51:20 | <Guest81> | I am reading "learn you a Haskell ..." and I am using interactive on the haskell.org homepage. But when I input a simple equality such as "a = [1,2,3]" is get a parse error. What am I doing wrong? |
| 2026-02-24 21:51:40 | <Rembane> | Guest81: Try a let a = [1,2,3] |
| 2026-02-24 21:51:55 | <tomsmeding> | that "Try it!" prompt on haskell.org is not a proper haskell interpreter |
| 2026-02-24 21:52:02 | <EvanR> | a = [1,2,3] ought to work in ghci and at top level? |
| 2026-02-24 21:52:08 | <tomsmeding> | it doesn't there |
| 2026-02-24 21:52:20 | <Guest81> | no go: let a = [1,2,3] |
| 2026-02-24 21:52:21 | <Guest81> | <no location info>: not an expression: ‘let a = [1,2,3]’ |
| 2026-02-24 21:52:32 | <EvanR> | "interesting" |
| 2026-02-24 21:52:47 | <monochrom> | "a = [1,2,3]" works for me. |
| 2026-02-24 21:53:06 | <tomsmeding> | there's https://play.haskell.org if you want to upgrade to writing a full program (which doesn't have to be complicated!); otherwise, either install ghci, or there may be some other online repl |
| 2026-02-24 21:53:12 | <monochrom> | "let a = [1,2,3]" also works for me. |
| 2026-02-24 21:53:23 | <tomsmeding> | monochrom: we're talking about the "Try it!" thing on haskell.org, which is stupid and broken |
| 2026-02-24 21:53:35 | <monochrom> | Oh that. Sorry! |
| 2026-02-24 21:53:51 | <monochrom> | "let a = [1,2,3] in length a" |
| 2026-02-24 21:54:07 | <tomsmeding> | ah yes, that does work Guest81 ^ |
| 2026-02-24 21:54:18 | <monochrom> | But play.haskell.org is better. |
| 2026-02-24 21:54:19 | × | astra quits (sid289983@user/amish) (Server closed connection) |
| 2026-02-24 21:54:20 | <tomsmeding> | apparently it accepts only full expressions |
| 2026-02-24 21:54:31 | <tomsmeding> | play.haskell.org is not a repl, though :) |
| 2026-02-24 21:54:32 | × | prdak quits (~Thunderbi@user/prdak) (Ping timeout: 268 seconds) |
| 2026-02-24 21:54:33 | → | astra joins (sid289983@id-289983.hampstead.irccloud.com) |
All times are in UTC.