Logs: liberachat/#haskell
| 2021-08-14 21:31:34 | <Guest21> | sumOddSquares = sum . filter f $ map (^2) [1..] |
| 2021-08-14 21:31:34 | <Guest21> | where f x = odd x && x < 10000 |
| 2021-08-14 21:31:50 | <Guest21> | My function runs forever for some reason. |
| 2021-08-14 21:32:40 | <monochrom> | If you find a GHC version that can't be persuaded to do non-latin-1 I/O, take note that its Char type is still big enough for all of Unicode, it's just the I/O routines that disappoint. |
| 2021-08-14 21:32:41 | <hololeap> | Guest21: use the takeWhile function |
| 2021-08-14 21:32:56 | <Guest21> | Sure, but why doesn't it work like I wrote? |
| 2021-08-14 21:32:57 | × | wonko quits (~wjc@62.115.229.50) (Ping timeout: 268 seconds) |
| 2021-08-14 21:33:16 | <hololeap> | because there is nothing that tells it to stop |
| 2021-08-14 21:33:34 | <hololeap> | it doesn't know you want to stop at 10000 |
| 2021-08-14 21:33:35 | <Guest21> | what happens to my x < 10 000? |
| 2021-08-14 21:33:47 | <monochrom> | If you start with [1, 3 .. 10000] you have all odd numbers below 10000 in the first place. |
| 2021-08-14 21:34:02 | <hololeap> | the filter function just continues returning False for infinity. it doesn't know to do anything else |
| 2021-08-14 21:34:15 | <Guest21> | Oh that's the answer I wanted, thanks! |
| 2021-08-14 21:34:21 | <Guest21> | hololeap |
| 2021-08-14 21:34:55 | <hololeap> | np |
| 2021-08-14 21:35:07 | <monochrom> | You should take a close look at the code of filter and hand-execute it to see what it really does. |
| 2021-08-14 21:36:06 | <monochrom> | As opposed to taking an "intuitive" wordy narrative that is completely open to misinterpretation therefore you can misunderstand it and indeed you did. |
| 2021-08-14 21:36:19 | → | machinedgod joins (~machinedg@24.105.81.50) |
| 2021-08-14 21:36:24 | <monochrom> | A formula is worth a thousand pictures. Which is a million words. |
| 2021-08-14 21:36:28 | <hololeap> | yeah, the code doesn't lie |
| 2021-08-14 21:38:58 | × | fvr quits (uid503686@id-503686.highgate.irccloud.com) (Quit: Connection closed for inactivity) |
| 2021-08-14 21:39:55 | <monochrom> | Maybe I should put that on my exam too. |
| 2021-08-14 21:41:53 | <monochrom> | Is this Project Euler? |
| 2021-08-14 21:42:54 | <monochrom> | Did Project Euler not place a very visible banner reminding you you're supposed to math the sh*t out of it and think up a basically O(1)-time algorithm and that should be what you code up, as opposed to brute-forcing it? |
| 2021-08-14 21:43:47 | <aarchi> | Are .hi files platform-independent? How compiler version-independent are they? |
| 2021-08-14 21:44:04 | <geekosaur> | they're very version-dependent |
| 2021-08-14 21:44:12 | <monochrom> | I still don't get it when people, even today, use it for "learning to code". What is the value in learning to code up only brute forcing, really? |
| 2021-08-14 21:44:44 | <aarchi> | Can a .hs file be reverse engineered from a .hi file? |
| 2021-08-14 21:44:49 | <Cajun> | its very good for learning how to google the right thing to find the right algorithm :P |
| 2021-08-14 21:44:49 | <geekosaur> | in fact they start out with a version indicator so the compiler can abort if a .hi file for the wrong version is used |
| 2021-08-14 21:45:06 | <geekosaur> | it doesn't have enough infoprmation to recreate a .hs file |
| 2021-08-14 21:45:24 | <hpc> | i think you need both the .hi and the .o file to have a chance |
| 2021-08-14 21:45:26 | <aarchi> | Does it have AST/source information? An IR? |
| 2021-08-14 21:45:53 | <aarchi> | What's in an .hi file? |
| 2021-08-14 21:46:21 | <geekosaur> | all it has is enough type information to use a .o fileproperly, and source unfoldings for cross-module inlining (whicyh applies only to small functions) |
| 2021-08-14 21:48:13 | <geekosaur> | you can use ghc to dump a .hi file in human-readable file (ghc --print-hi-file iirc) |
| 2021-08-14 21:49:20 | <aarchi> | I've got this .hi/.o pair, but no .hs source and I'd like to reverse engineer it: |
| 2021-08-14 21:49:21 | <aarchi> | https://web.archive.org/web/20030624020343/http://www.dur.ac.uk/d.j.walrond/whitespace/whitespace-0.1/VM.hi |
| 2021-08-14 21:49:25 | <aarchi> | https://web.archive.org/web/20030624020612/http://www.dur.ac.uk/d.j.walrond/whitespace/whitespace-0.1/VM.o |
| 2021-08-14 21:49:47 | <aarchi> | I have a later version of VM.hs, but want to derive this version |
| 2021-08-14 21:49:56 | <geekosaur> | sorry, it's --show-iface |
| 2021-08-14 21:50:50 | <geekosaur> | and I don't think you have enough information to derive that VM.hs |
| 2021-08-14 21:53:56 | × | Guest21 quits (~Guest21@2a02:aa1:1010:e9f8:8986:a924:83c:1c23) (Quit: Client closed) |
| 2021-08-14 21:54:58 | <aarchi> | I get "bad CPU type in executable" for both --print-hi-file and --show-iface. I'll have to try it in Docker |
| 2021-08-14 21:55:10 | <aarchi> | I guess that means that .hi files are plat-dependent |
| 2021-08-14 21:55:44 | <aarchi> | geekosaur: you said the GHC version is at the start of the .hi; I don't see it with xxd/less or strings |
| 2021-08-14 21:57:14 | × | __monty__ quits (~toonn@user/toonn) (Quit: leaving) |
| 2021-08-14 21:57:47 | <geekosaur> | aarchi, it's numerically encoded |
| 2021-08-14 21:58:11 | <geekosaur> | and that error actualy means you can't even run ghc |
| 2021-08-14 21:59:14 | <aarchi> | Looks like I forgot to cleanup my installation after experimenting with 6.2.1 |
| 2021-08-14 21:59:36 | <monochrom> | Yeah "executable" refers to GHC itself. |
| 2021-08-14 22:00:42 | × | hendursa1 quits (~weechat@user/hendursaga) (Ping timeout: 244 seconds) |
| 2021-08-14 22:01:27 | × | Guest54 quits (~Guest54@187.83.249.216.dyn.smithville.net) (Quit: Client closed) |
| 2021-08-14 22:03:04 | → | hendursa1 joins (~weechat@user/hendursaga) |
| 2021-08-14 22:04:34 | × | dudek quits (~dudek@185.150.236.112) (Quit: Leaving) |
| 2021-08-14 22:05:56 | <aarchi> | Well unfortunately the .hi version (after fixing my GHC install) isn't very indicative: |
| 2021-08-14 22:05:58 | <aarchi> | magic number mismatch: old/corrupt interface file? (wanted 33214052, got 0) |
| 2021-08-14 22:06:19 | <aarchi> | Does 0 correspond to any specific version(s)? |
| 2021-08-14 22:06:57 | <geekosaur> | means it's too old to have a version |
| 2021-08-14 22:07:48 | <geekosaur> | probably need to build the version of ghc it came from (5.02?) to dump it |
| 2021-08-14 22:09:51 | × | gehmehgeh quits (~user@user/gehmehgeh) (Quit: Leaving) |
| 2021-08-14 22:10:58 | <aarchi> | Fun stuff |
| 2021-08-14 22:13:41 | <geekosaur> | hm, that alos means --show-iface will only work with the same ghc that generated the .hi file :/ |
| 2021-08-14 22:14:23 | <hpc> | hopefully it wasn't a HEAD build |
| 2021-08-14 22:16:21 | × | mjs2600 quits (~mjs2600@c-24-91-3-49.hsd1.vt.comcast.net) (Quit: ZNC 1.8.2 - https://znc.in) |
| 2021-08-14 22:16:21 | × | machinedgod quits (~machinedg@24.105.81.50) (Read error: Connection reset by peer) |
| 2021-08-14 22:16:35 | <geekosaur> | I wonderif 5.02 will even build with a modernish ghc |
| 2021-08-14 22:16:40 | → | machinedgod joins (~machinedg@24.105.81.50) |
| 2021-08-14 22:16:47 | <geekosaur> | might have to walk backwards a major version at a time |
| 2021-08-14 22:17:29 | × | slowButPresent quits (~slowButPr@user/slowbutpresent) (Quit: leaving) |
| 2021-08-14 22:17:44 | → | mjs2600 joins (~mjs2600@c-24-91-3-49.hsd1.vt.comcast.net) |
| 2021-08-14 22:18:23 | × | eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection) |
| 2021-08-14 22:19:01 | → | slowButPresent joins (~slowButPr@user/slowbutpresent) |
| 2021-08-14 22:21:08 | <aarchi> | I'm hoping I don't have to bootstrap GHC |
| 2021-08-14 22:21:24 | <aarchi> | Can GHC cross compile itself? |
| 2021-08-14 22:22:15 | <geekosaur> | there's a backward compatibility policy, but afaik no forward compatibility policy |
| 2021-08-14 22:22:35 | <geekosaur> | so there's no guarantee modern ghc can build an older one |
| 2021-08-14 22:23:14 | × | acidjnk quits (~acidjnk@p200300d0c72b9508a1e806c8914cbd0f.dip0.t-ipconnect.de) (Ping timeout: 272 seconds) |
| 2021-08-14 22:23:48 | <aarchi> | And I don't think I could usefully build newer a GHC from an older one because that couldn't produce a platform that isn't published online |
| 2021-08-14 22:27:26 | × | Tuplanolla quits (~Tuplanoll@91-159-69-50.elisa-laajakaista.fi) (Quit: Leaving.) |
| 2021-08-14 22:29:19 | <stevenxl> | Hey folks. I have a value of type (MonadReader env m) => ReaderT SqlBackend m (), and I want to define it in terms of another value of type (MonadReader Int m) => ReaderT SqlBackend m (). |
| 2021-08-14 22:29:29 | stevenxl | Script is here: https://paste.tomsmeding.com/6JBwFuFo |
| 2021-08-14 22:30:10 | stevenxl | I can get this to compile by peeling off the first monadic context, and then manually running the second monadic context. |
| 2021-08-14 22:30:12 | stevenxl | Is there a better way/ |
| 2021-08-14 22:32:27 | × | hendursa1 quits (~weechat@user/hendursaga) (Quit: hendursa1) |
| 2021-08-14 22:33:17 | → | hendursaga joins (~weechat@user/hendursaga) |
| 2021-08-14 22:33:34 | → | lavaman joins (~lavaman@98.38.249.169) |
| 2021-08-14 22:36:44 | × | aguapesada quits (~aguapesad@2804:14c:8793:8e2f:311f:1da6:1cf6:61ea) (Read error: Connection reset by peer) |
| 2021-08-14 22:38:26 | × | lavaman quits (~lavaman@98.38.249.169) (Ping timeout: 272 seconds) |
| 2021-08-14 22:42:58 | <dminuoso> | stevenxl: The type signatures you wrote in IRC dont work. |
| 2021-08-14 22:43:44 | <stevenxl> | I may have explained myself incorrectly. The snippet does compile: |
| 2021-08-14 22:43:48 | <stevenxl> | https://www.irccloud.com/pastebin/93RjtIYP/ |
| 2021-08-14 22:44:05 | <stevenxl> | I was just wondering if there is a more elegant way of doing this. |
| 2021-08-14 22:45:14 | <dminuoso> | You could ImplicitParams, perhaps. |
| 2021-08-14 22:45:27 | <dminuoso> | Or consider explicitly passing arguments, rather than relying on ReaderT. |
| 2021-08-14 22:45:59 | <dminuoso> | Also perhaps `local` is an option if the nested computations environment can be pulled from the outer environment using a function. |
| 2021-08-14 22:46:07 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-08-14 22:46:11 | <dminuoso> | Those are the options that I can see |
| 2021-08-14 22:47:21 | stevenxl | Yea - in production I went with passing in the argument explicitly to `funcTwo`, and I did see the `local` option as well. I don't know about ImplicitParams so I might have to look that up. |
| 2021-08-14 22:47:40 | stevenxl | `mapReaderT` sounded like something worthwhile but I can't get it to work. |
All times are in UTC.