Logs: liberachat/#haskell
| 2025-10-10 19:04:02 | → | Everything joins (~Everythin@46.96.48.125) |
| 2025-10-10 19:05:52 | × | chexum quits (~quassel@gateway/tor-sasl/chexum) (Ping timeout: 272 seconds) |
| 2025-10-10 19:06:02 | → | chexum joins (~quassel@gateway/tor-sasl/chexum) |
| 2025-10-10 19:06:37 | × | merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 264 seconds) |
| 2025-10-10 19:14:29 | × | n0den1te quits (~n0den1te@42.111.145.186) (Quit: leaving) |
| 2025-10-10 19:15:44 | × | Googulator36 quits (~Googulato@2a01-036d-0106-03fa-dc7a-fb6e-71bb-aaf0.pool6.digikabel.hu) (Quit: Client closed) |
| 2025-10-10 19:15:46 | → | Googulator10 joins (~Googulato@193-226-241-224.pool.digikabel.hu) |
| 2025-10-10 19:17:05 | → | merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl) |
| 2025-10-10 19:22:21 | × | merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 256 seconds) |
| 2025-10-10 19:32:53 | → | merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl) |
| 2025-10-10 19:37:43 | × | merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds) |
| 2025-10-10 19:48:41 | → | merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl) |
| 2025-10-10 19:54:01 | × | merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 264 seconds) |
| 2025-10-10 19:55:30 | → | peterbecich joins (~Thunderbi@syn-172-222-148-214.res.spectrum.com) |
| 2025-10-10 19:55:47 | → | karenw joins (~karenw@user/karenw) |
| 2025-10-10 19:57:45 | → | Tri joins (~Tri@69.74.159.34) |
| 2025-10-10 19:58:28 | × | inline quits (~inline@2a02:8071:57a1:1260:2c74:3485:fb3b:d86d) (Quit: Leaving) |
| 2025-10-10 19:59:36 | × | fgidim quits (~nu@user/fgarcia) (Quit: Remote host closed the connection) |
| 2025-10-10 20:00:30 | <Tri> | https://paste.tomsmeding.com/ItCU0RWx |
| 2025-10-10 20:00:30 | <Tri> | Hi, I'm beginner. My program is calling a table and returns many rows.I'd like to extract only a few rows to test interactively in GHCI to debug my logic. How could I do that please? I can't realistically new up these objects because that's very tedious. |
| 2025-10-10 20:01:28 | <Tri> | thank you for your help |
| 2025-10-10 20:03:16 | <mauke> | you can run statements like 'conn <- connectODBC "Driver={ODBC Driver 17 for SQL Server};Server=BDEverest;Database=BDDataWH;Trusted_Connection=yes;"' directly in ghci |
| 2025-10-10 20:03:49 | int-e | would split up `main` into several functions so that they become available in ghci |
| 2025-10-10 20:05:06 | → | merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl) |
| 2025-10-10 20:05:20 | <int-e> | (cut&paste works too but doesn't scale well if, for example, the connection logic becomes more complex) |
| 2025-10-10 20:06:00 | → | bgg joins (~bgg@2a01:e0a:819:1510:fae0:116a:81b6:6ffd) |
| 2025-10-10 20:07:04 | → | inline joins (~inline@2a02:8071:57a1:dc0:8439:c652:7e44:c6fc) |
| 2025-10-10 20:07:04 | <Tri> | mauke I did copied separately these into ghci, but got |
| 2025-10-10 20:07:05 | <Tri> | conn <- connectODBC "Driver={ODBC Driver 17 for SQL Server};Server=BDEverest;Database=BDDataWH;Trusted_Connection=yes;" |
| 2025-10-10 20:07:05 | <Tri> | and |
| 2025-10-10 20:07:06 | <Tri> | queryResult <- quickQuery' conn "SELECT * from Reference.IssuerAssetOverride where wsoissuerid = 5950" [] |
| 2025-10-10 20:07:06 | <Tri> | ghci> conn <- connectODBC "Driver={ODBC Driver 17 for SQL Server};Server=BDEverest;Database=BDDataWH;Tr" |
| 2025-10-10 20:07:07 | <Tri> | ghci> queryResult <- quickQuery' conn "SELECT * from Reference.IssuerAssetOverride where wsoissuerid = ] |
| 2025-10-10 20:07:07 | <Tri> | *** Exception: SqlError {seState = "", seNativeError = -1, seErrorMsg = "Tried to use a disposed ODBC Connection handle"} |
| 2025-10-10 20:08:28 | <Tri> | thank you int-e, I will try to break down the main function |
| 2025-10-10 20:09:03 | <int-e> | Huh, shouldn't having the `conn` value keep the connection alive? |
| 2025-10-10 20:10:29 | <Tri> | int-e I just tried again, separately copied and pasting these 2 rows throw the exception |
| 2025-10-10 20:11:44 | × | merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds) |
| 2025-10-10 20:11:58 | <int-e> | Tri: Oh I believe you. Basically I'm wondering whether this is a bug. |
| 2025-10-10 20:13:05 | <Tri> | int-e, however, thanks to your susggestion to break down into smaller function, I can now get them in ghci, now I have |
| 2025-10-10 20:13:05 | <Tri> | testGetRow = do |
| 2025-10-10 20:13:06 | <Tri> | conn <- connectODBC "Driver={ODBC Driver 17 for SQL Server};Server=BDEverest;Database=BDDataWH;Trusted_Connection=yes;" |
| 2025-10-10 20:13:06 | <Tri> | queryResult <- quickQuery' conn "SELECT * from Reference.IssuerAssetOverride where wsoissuerid = 5950" [] |
| 2025-10-10 20:13:07 | <Tri> | return $ map fromSqlToOverride queryResult |
| 2025-10-10 20:13:07 | <Tri> | However, having to write additional script just to test in ghci doesn't feel elegant to me |
| 2025-10-10 20:13:08 | <Tri> | And, if I decide to use this as my official code, then I need to return the conn from the function, so that I can close it in the main function. This makes the function having more responsibility than it should be |
| 2025-10-10 20:14:57 | <Tri> | int-e https://paste.tomsmeding.com/rU8mWvfq |
| 2025-10-10 20:15:30 | <Tri> | How can I do it better? Thank you |
| 2025-10-10 20:19:51 | <int-e> | It's fine, though I'd probably separate out the connection step because it's so different from issuing a query |
| 2025-10-10 20:20:38 | → | Googulator29 joins (~Googulato@2a01-036d-0106-03fa-dc7a-fb6e-71bb-aaf0.pool6.digikabel.hu) |
| 2025-10-10 20:20:47 | × | Googulator10 quits (~Googulato@193-226-241-224.pool.digikabel.hu) (Quit: Client closed) |
| 2025-10-10 20:21:27 | <int-e> | I'm still more interested in why the copy&paste fails. I guess apart from FFI/GC woes, it could also be caused by a DB server that aggressively times out connections. |
| 2025-10-10 20:23:09 | → | merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl) |
| 2025-10-10 20:24:15 | × | michalz quits (~michalz@185.246.207.200) (Remote host closed the connection) |
| 2025-10-10 20:28:49 | × | peterbecich quits (~Thunderbi@syn-172-222-148-214.res.spectrum.com) (Ping timeout: 264 seconds) |
| 2025-10-10 20:30:56 | → | inline_ joins (~inline@2a02:8071:57a1:1260:249e:867e:200a:1fb1) |
| 2025-10-10 20:33:11 | × | merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 256 seconds) |
| 2025-10-10 20:34:43 | × | inline quits (~inline@2a02:8071:57a1:dc0:8439:c652:7e44:c6fc) (Ping timeout: 250 seconds) |
| 2025-10-10 20:36:12 | → | Zemy_ joins (~Zemy@syn-072-176-124-082.res.spectrum.com) |
| 2025-10-10 20:36:13 | × | Zemy quits (~Zemy@syn-072-176-124-082.res.spectrum.com) (Read error: Connection reset by peer) |
| 2025-10-10 20:37:31 | → | Zemy joins (~Zemy@2600:100c:b004:cbe8:54ca:29ff:fe47:5f3) |
| 2025-10-10 20:37:31 | × | Zemy_ quits (~Zemy@syn-072-176-124-082.res.spectrum.com) (Read error: Connection reset by peer) |
| 2025-10-10 20:38:46 | → | Zemy_ joins (~Zemy@syn-072-176-124-082.res.spectrum.com) |
| 2025-10-10 20:41:13 | → | ljdarj1 joins (~Thunderbi@user/ljdarj) |
| 2025-10-10 20:41:49 | × | Zemy quits (~Zemy@2600:100c:b004:cbe8:54ca:29ff:fe47:5f3) (Ping timeout: 260 seconds) |
| 2025-10-10 20:43:42 | × | ljdarj quits (~Thunderbi@user/ljdarj) (Ping timeout: 252 seconds) |
| 2025-10-10 20:43:42 | ljdarj1 | is now known as ljdarj |
| 2025-10-10 20:50:28 | → | pavonia joins (~user@user/siracusa) |
| 2025-10-10 20:58:55 | → | rvalue joins (~rvalue@about/hackers/rvalue) |
| 2025-10-10 20:59:50 | <EvanR> | Tri, in practice it's pretty annoying to first write a script in ghci and then rewrite it in a file later |
| 2025-10-10 21:00:24 | <EvanR> | better workflow: write the script in a file and issue a reload command in ghci when it's updated |
| 2025-10-10 21:00:35 | <EvanR> | then call the commands defined in there |
| 2025-10-10 21:01:00 | × | takuan quits (~takuan@d8D86B9E9.access.telenet.be) (Remote host closed the connection) |
| 2025-10-10 21:01:05 | <EvanR> | this is actually good in many languages with a REPL when it works |
| 2025-10-10 21:03:24 | <mauke> | this is why REPLs are largely useless |
| 2025-10-10 21:04:53 | → | target_i joins (~target_i@user/target-i/x-6023099) |
| 2025-10-10 21:09:18 | <Tri> | EvanR better workflow: write the script in a file and issue a reload command in ghci when it's updated |
| 2025-10-10 21:09:19 | <Tri> | sorry I don't follow this, how should refactor my program according to your advice so I could test it better? https://paste.tomsmeding.com/ItCU0RWx |
| 2025-10-10 21:13:30 | → | jespada joins (~jespada@2800:a4:223d:e100:e1e1:d06f:e056:da4) |
| 2025-10-10 21:14:12 | × | Everything quits (~Everythin@46.96.48.125) (Quit: leaving) |
| 2025-10-10 21:14:15 | × | __monty__ quits (~toonn@user/toonn) (Quit: leaving) |
| 2025-10-10 21:16:12 | → | jmcantrell joins (~weechat@user/jmcantrell) |
| 2025-10-10 21:17:53 | × | jespada quits (~jespada@2800:a4:223d:e100:e1e1:d06f:e056:da4) (Client Quit) |
| 2025-10-10 21:22:02 | <pavonia> | Tri: I think the suggestion was just to have your definitions in a separate file and load this into GHCi, as opposed to write all your definitions in the REPL directly |
| 2025-10-10 21:26:04 | <Tri> | pavonia I write everything in a file, and use cabal repl and to load and execute whatever I want to test |
| 2025-10-10 21:26:25 | <Tri> | every time i change something I do a reload :r and re-run |
| 2025-10-10 21:26:41 | <pavonia> | Sounds good |
| 2025-10-10 21:27:02 | <Tri> | And I was having trouble trying to just pick out a subset of rows return the sql call, instead of the whole table |
| 2025-10-10 21:28:29 | <Tri> | and as they suggest I refactor the table call into a separate function, https://paste.tomsmeding.com/rU8mWvfq |
| 2025-10-10 21:28:30 | <Tri> | but it doesn't look elegant, because I have to return a conn to dispose later. And it doesn't look elegant having to write extra code to test in ghci |
| 2025-10-10 21:29:35 | × | tromp quits (~textual@2001:1c00:3487:1b00:409c:634b:fec4:4fe) (Quit: My iMac has gone to sleep. ZZZzzz…) |
| 2025-10-10 21:33:05 | <pavonia> | Are you familiar with monad transformers? In this case you could use a ReaderT or StateT monad to "hide" the connection in a new monad |
| 2025-10-10 21:33:27 | <Tri> | I am... a bit... but that just escalated very quickly... |
| 2025-10-10 21:33:37 | <Tri> | I just want to test a piece of data in GHCI... |
| 2025-10-10 21:33:52 | <Tri> | anyway I gotta catch my train now. Thank you for your help. I will post this on Reddit |
| 2025-10-10 21:34:05 | <Tri> | This is ridiculously difficult compared to F# |
| 2025-10-10 21:36:18 | → | peterbecich joins (~Thunderbi@syn-172-222-148-214.res.spectrum.com) |
| 2025-10-10 21:43:00 | inline_ | is now known as Inline |
| 2025-10-10 21:49:04 | Zemy_ | is now known as Zemy |
| 2025-10-10 21:52:11 | → | AlexNoo_ joins (~AlexNoo@178.34.151.169) |
All times are in UTC.