Logs: freenode/#haskell
| 2020-09-19 17:20:38 | <dmwit> | do { args <- getArgs; contents <- readFile (head args); putStr contents } |
| 2020-09-19 17:20:53 | <dmwit> | You might also like The IO Monad for People Who Simply Don't Care. |
| 2020-09-19 17:21:02 | <dmwit> | http://blog.sigfpe.com/2007/11/io-monad-for-people-who-simply-dont.html |
| 2020-09-19 17:21:54 | <lechner> | in an earlier experiment, the assignment args <- getArgs seemed to make a difference. is that possible? |
| 2020-09-19 17:22:05 | <lechner> | instead of using getArgs straight |
| 2020-09-19 17:22:31 | <dmwit> | Take a look at my link and you will have a framework for understanding why that made a difference. |
| 2020-09-19 17:22:43 | → | Thra11 joins (~Thra11@5.1.169.217.in-addr.arpa) |
| 2020-09-19 17:22:46 | <dmwit> | (Yes, it is possible.) |
| 2020-09-19 17:23:27 | hackage | uniqueness-periods-vector-stats 0.1.1.0 - A very basic descriptive statistics. https://hackage.haskell.org/package/uniqueness-periods-vector-stats-0.1.1.0 (OleksandrZhabenko) |
| 2020-09-19 17:24:50 | <sm[m]> | https://paste.tomsmeding.com/PZbIiTyi is the simplest fix, as dmwit said |
| 2020-09-19 17:25:56 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2020-09-19 17:26:04 | <lechner> | i am reading and will be back with more shortly. thanks for being so friendly. don't know why people say haskellers are complicated folks :) |
| 2020-09-19 17:26:46 | × | fendor quits (~fendor@212095005091.public.telering.at) (Ping timeout: 272 seconds) |
| 2020-09-19 17:26:55 | × | kish` quits (~oracle@unaffiliated/oracle) (Remote host closed the connection) |
| 2020-09-19 17:27:14 | → | kish joins (~oracle@unaffiliated/oracle) |
| 2020-09-19 17:27:17 | × | mpereira quits (~mpereira@2a02:810d:f40:d96:b46b:1e98:8653:4550) (Ping timeout: 272 seconds) |
| 2020-09-19 17:27:35 | → | ukari joins (~ukari@unaffiliated/ukari) |
| 2020-09-19 17:27:43 | <sm[m]> | I know! We are all simple folk here |
| 2020-09-19 17:28:05 | <sm[m]> | tomsmeding: should Edit this paste be Clone this paste ? (Also, links between such pastes could be nifty) |
| 2020-09-19 17:28:10 | → | teardown joins (~user@unaffiliated/mrush) |
| 2020-09-19 17:28:35 | <tomsmeding> | it should |
| 2020-09-19 17:28:48 | <tomsmeding> | in fact I have a todo for that |
| 2020-09-19 17:28:52 | <lechner> | hi, when reading files, is it better to use strict or lazy variants, please? |
| 2020-09-19 17:28:57 | → | josh joins (~josh@c-67-164-104-206.hsd1.ca.comcast.net) |
| 2020-09-19 17:29:09 | <tomsmeding> | I like "Clone", too |
| 2020-09-19 17:29:13 | <davean> | lechner: depends on what you want to accomplish. |
| 2020-09-19 17:29:26 | <dmwit> | lechner: Lazy IO is to be avoided in real code. For quick experiments while learning, it is fine. |
| 2020-09-19 17:29:28 | <merijn> | The answer is: use strict or use conduit :p |
| 2020-09-19 17:29:37 | <merijn> | (or some other streaming library) |
| 2020-09-19 17:29:39 | <lechner> | thank you |
| 2020-09-19 17:29:54 | <lechner> | why is lazy I/O a bad idea? |
| 2020-09-19 17:30:02 | <merijn> | lechner: It's hard to control cleanup |
| 2020-09-19 17:30:19 | <lechner> | space leaks? |
| 2020-09-19 17:30:22 | <davean> | lechner: consider if you're reading lazily while writing to it. |
| 2020-09-19 17:30:24 | <merijn> | lechner: File descriptors (aka handles) are a limited resource and lazy IO makes it hard to control if/when they are freed |
| 2020-09-19 17:30:24 | <davean> | lechner: what do you get? |
| 2020-09-19 17:30:28 | <dmwit> | lechner: https://stackoverflow.com/a/6669453/791604 describes why lazy IO is a bad idea |
| 2020-09-19 17:30:45 | <dolio> | I think lazy I/O is a good idea. :þ |
| 2020-09-19 17:30:49 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 264 seconds) |
| 2020-09-19 17:30:54 | → | Saten-san joins (~Saten-san@ip-81-11-153-236.dsl.scarlet.be) |
| 2020-09-19 17:31:00 | <Uniaika> | dolio: I curse you to hell and back |
| 2020-09-19 17:31:18 | × | walla quits (47b88ff9@pool-71-184-143-249.bstnma.fios.verizon.net) (Remote host closed the connection) |
| 2020-09-19 17:31:31 | <davean> | lechner: the idea of spaceleaks with laziness is a bit weird, since strict has to use all the space, lazy only might use all the space. |
| 2020-09-19 17:31:32 | × | ransom quits (~c4264035@2603:300b:1301:3d00:a40f:9b09:1376:26b9) (Ping timeout: 244 seconds) |
| 2020-09-19 17:31:36 | <glguy> | If your goal is to write a program that opens a file, computes the SHA-512 hash, and prints that; then the lazy IO version will work the same as the strict IO version but probably use less ram |
| 2020-09-19 17:32:01 | <lechner> | it's the first line in a bigger project |
| 2020-09-19 17:32:02 | <merijn> | glguy: But then it'd be very little work to use conduit or some such and be sure of that fact ;) |
| 2020-09-19 17:32:19 | <merijn> | Not to mention that learning 1 or more streaming libraries is worthwhile anyway since they're amazing |
| 2020-09-19 17:32:22 | <dmwit> | davean: Sure. But lazy encourages a style of programming that would, in a strict semantics, use much more memory than the idiomatic approach from a strict language. |
| 2020-09-19 17:32:34 | <merijn> | Beat the shit out of nearly anything I've encountered in any other language for such problems |
| 2020-09-19 17:33:14 | <dolio> | Streaming libraries are exactly the overcomplicated solution for simple intro examples. |
| 2020-09-19 17:33:27 | <dmwit> | ^ |
| 2020-09-19 17:33:32 | <merijn> | Sure |
| 2020-09-19 17:33:33 | <dolio> | And are probably an example of why people think Haskell people are complicated. |
| 2020-09-19 17:33:57 | <lechner> | actually, i think it's because of category theory |
| 2020-09-19 17:34:12 | <davean> | dmwit: I mean that sounds a lot like the tautology of "if you used more memory, you'd use more memory". |
| 2020-09-19 17:34:26 | <geekosaur> | you need zero category theory to use Haskell |
| 2020-09-19 17:34:29 | <merijn> | lechner: Category theory has basically zero relevance to haskell projects (or even Haskell) |
| 2020-09-19 17:34:51 | <merijn> | lechner: I dunno where that meme got started on the internet, but it's 100% nonsense |
| 2020-09-19 17:35:16 | <dolio> | Also note that one of the negatives about lazy I/O brought up (what if you read and write to a file concurrently) also applies to streaming libraries, but no one blames the streaming libraries for it for some reason. |
| 2020-09-19 17:35:49 | <merijn> | lechner: I've been doing Haskell for, like, a decade now. Very productively even, and I still got lost about 2-3 chapters into any book on category theory :p |
| 2020-09-19 17:35:57 | <davean> | dolio: uh, doesn't happen when I use 'machines' for example, I can can control the reading and writing so I can know what happens exactly. |
| 2020-09-19 17:36:06 | <merijn> | dolio: Files are shit, let's replace everything with SQLite databases :D |
| 2020-09-19 17:36:10 | <davean> | dolio: infact I use 'machines' specificly for reading and writing to a file at the same time. |
| 2020-09-19 17:36:27 | hackage | texmath 0.12.0.3 - Conversion between formats used to represent mathematics. https://hackage.haskell.org/package/texmath-0.12.0.3 (JohnMacFarlane) |
| 2020-09-19 17:36:56 | <lechner> | is there a kindred spririt between haskell and the declarative nature of SQL? |
| 2020-09-19 17:37:23 | <merijn> | Kinda, maybe? |
| 2020-09-19 17:37:46 | → | Sgeo joins (~Sgeo@ool-18b982ad.dyn.optonline.net) |
| 2020-09-19 17:37:47 | <davean> | dolio: yah, I'm not sure why you think the concurrency would be an issue with a streaming library. |
| 2020-09-19 17:37:48 | <merijn> | SQL (at least, the non-write statements) is purely functional, after all :) |
| 2020-09-19 17:37:55 | → | DavidEichmann joins (~david@43.240.198.146.dyn.plus.net) |
| 2020-09-19 17:37:56 | <ddellacosta> | merijn: re: category theory in Haskell, I think the unfortunate truth is that as soon as people see words like "Functor" they assume that Haskell is a morass of abstract nonsense and stop thinking there |
| 2020-09-19 17:38:01 | × | DavidEichmann quits (~david@43.240.198.146.dyn.plus.net) (Remote host closed the connection) |
| 2020-09-19 17:38:22 | <sm[m]> | conduit is awesome but a bit too much for someone writing their first haskell program |
| 2020-09-19 17:38:35 | <merijn> | Well, that wasn't really specified :p |
| 2020-09-19 17:38:48 | <sm[m]> | twas, twas |
| 2020-09-19 17:38:52 | <merijn> | The question was "lazy or strict" :p |
| 2020-09-19 17:38:54 | <dolio> | davean: Because streaming libraries don't solve having to not be naive about interleaving your reading and writing to a single file, which is what people blame lazy I/O for. |
| 2020-09-19 17:39:13 | <merijn> | dolio: Nobody claimed streaming libraries solved "all problems ever" so that seems a bit of a strawman |
| 2020-09-19 17:39:15 | <davean> | dolio: they can dothat. |
| 2020-09-19 17:39:15 | <geekosaur> | that's only one of the problems with lazy I/O |
| 2020-09-19 17:39:33 | <davean> | dolio: for example, only executing the writes to already read parts. |
| 2020-09-19 17:39:52 | <davean> | and delaying the ones to pending reads. |
| 2020-09-19 17:39:58 | <merijn> | Also, I don't think anyone thinks "simultaneous read and writes" is the problem with lazy IO, considering none of the streaming libraries even talk about that in any motivation |
| 2020-09-19 17:40:27 | <dolio> | merijn: Then they should stop using it as an example of lazy I/O being a problem. |
| 2020-09-19 17:40:47 | <merijn> | dolio: I've literally never seen that brought up as a lazy IO problem except just now on IRC |
| 2020-09-19 17:41:01 | <dolio> | Well I've seen it multiple times in the past on IRC. |
| 2020-09-19 17:41:04 | × | dansho quits (~dansho@ip68-108-167-185.lv.lv.cox.net) (Quit: Leaving) |
| 2020-09-19 17:42:08 | <davean> | dolio: to be clear I brought it up about lazy vs. strict io, not streaming. Streaming systems can't solve problems without you deciding what you want. |
| 2020-09-19 17:42:10 | <sm[m]> | lechner, please ask less controversial questions in future (j/k :) |
| 2020-09-19 17:42:18 | <merijn> | Yes |
| 2020-09-19 17:42:27 | <merijn> | Like "how do I get 'a' out of 'IO a'?" ;) |
| 2020-09-19 17:42:49 | <davean> | merijn: well, you just pattern match on (# RealWorld, ... #) ... |
| 2020-09-19 17:43:21 | <merijn> | ;) |
| 2020-09-19 17:43:34 | <davean> | Or use the Comonad instance of IO |
| 2020-09-19 17:44:04 | <davean> | which is easy to write with unsafePerformIO |
| 2020-09-19 17:44:07 | <davean> | laws aside |
| 2020-09-19 17:44:17 | <tomsmeding> | :D |
| 2020-09-19 17:44:23 | × | MaoZeDong_ quits (~yuri@2a00:1370:8135:91d4:415b:9b05:36f8:565c) (Ping timeout: 272 seconds) |
| 2020-09-19 17:44:31 | <monochrom> | http://www.vex.net/~trebla/photo/unorganized/IO-String.png |
All times are in UTC.