Logs: freenode/#haskell
| 2020-10-03 23:46:41 | × | vicfred quits (~vicfred@unaffiliated/vicfred) (Quit: Leaving) |
| 2020-10-03 23:46:45 | <dsal> | e.g., instance FromJSON YourThing where parseJSON = genericParseJSON jsonOpts{ fieldLabelModifier = dropWhile '_' |
| 2020-10-03 23:46:51 | <dsal> | Something like that. And then a } |
| 2020-10-03 23:47:52 | × | ft quits (~ft@shell.chaostreff-dortmund.de) (Ping timeout: 260 seconds) |
| 2020-10-03 23:48:05 | <OmegaDoug> | dsal, thanks. I was looking for a concise solution. The other solutions I found online had a lot more code involved. I'll give that a try. |
| 2020-10-03 23:48:44 | <dsal> | fieldLabelModifier is a simple function that rewrites your field name to match a JSON field. You can do lots of things there pretty easily. |
| 2020-10-03 23:48:58 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection) |
| 2020-10-03 23:50:57 | × | finkata quits (~dpetrov@83.222.188.39) (Read error: Connection reset by peer) |
| 2020-10-03 23:54:12 | × | nbloomf quits (~nbloomf@2600:1700:83e0:1f40:683c:11e3:ba18:6adc) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-10-03 23:56:02 | → | d34df00d joins (~d34df00d@104-14-27-213.lightspeed.austtx.sbcglobal.net) |
| 2020-10-03 23:56:04 | <d34df00d> | Hi! |
| 2020-10-03 23:57:22 | <d34df00d> | I want to parse an XML file and fold over the values of some of the nodes. Is there anything that'd stream the file as well? |
| 2020-10-03 23:57:32 | <d34df00d> | I wrote something with hxt, but it seems to load the whole file in memory. |
| 2020-10-03 23:59:26 | <dsal> | I used xeno a while back. It was pretty easy. |
| 2020-10-03 23:59:29 | <d34df00d> | Namely, I wrote this, and, judging by memory consumption, it indeed loads the whole file: |
| 2020-10-03 23:59:34 | <d34df00d> | https://bpaste.net/RVMA |
| 2020-10-03 23:59:47 | <d34df00d> | dsal: thanks! Never used (or even heard about) xeno before, will look at ti! |
| 2020-10-04 00:00:02 | × | kers quits (~kers@185.204.1.185) () |
| 2020-10-04 00:00:28 | <dsal> | I don't have to deal with xml very much, so I don't know what's best, but that worked well for me. :) |
| 2020-10-04 00:00:52 | × | takuan quits (~takuan@178-116-218-225.access.telenet.be) (Remote host closed the connection) |
| 2020-10-04 00:01:18 | <d34df00d> | Yeah, same here. Last time I had to parse XML before was... well, I don't even remember! |
| 2020-10-04 00:01:39 | → | jedii joins (~g@209.6.150.53) |
| 2020-10-04 00:01:49 | <jedii> | anyoine using happstack.com? looks sick |
| 2020-10-04 00:02:04 | × | jedii quits (~g@209.6.150.53) (Quit: leaving) |
| 2020-10-04 00:05:41 | <d34df00d> | Dang, Xeno.SAX is strict on the bytestrings. |
| 2020-10-04 00:06:31 | <dsal> | I wasn't using it for anything big. |
| 2020-10-04 00:06:36 | <d34df00d> | …but there's bytestring-mmap! |
| 2020-10-04 00:07:00 | → | borne joins (~fritjof@200116b864ada80007933c164a08810c.dip.versatel-1u1.de) |
| 2020-10-04 00:10:25 | → | ft joins (~ft@shell.chaostreff-dortmund.de) |
| 2020-10-04 00:11:23 | × | livvy quits (~livvy@gateway/tor-sasl/livvy) (Ping timeout: 240 seconds) |
| 2020-10-04 00:16:30 | → | conal joins (~conal@66.115.157.94) |
| 2020-10-04 00:16:38 | × | cosimone quits (~cosimone@2001:b07:ae5:db26:b248:7aff:feea:34b6) (Quit: Quit.) |
| 2020-10-04 00:16:52 | <cohn> | hi, how do I create a minimal .cabal file for experimenting? |
| 2020-10-04 00:17:50 | × | jedws quits (~jedws@121.209.139.222) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-10-04 00:18:38 | → | jedws joins (~jedws@121.209.139.222) |
| 2020-10-04 00:18:55 | × | Tuplanolla quits (~Tuplanoll@91-159-68-239.elisa-laajakaista.fi) (Ping timeout: 240 seconds) |
| 2020-10-04 00:20:13 | × | jgt quits (~jgt@188.239.64.32) (Ping timeout: 265 seconds) |
| 2020-10-04 00:20:35 | <OmegaDoug> | Aeson fieldLabelModifier doesn't seem to get applied to by data type. I can't see what I'm doing which is different from any online example. I'm wondering if I could get a second set of eyes: https://gist.github.com/DouglasBrunner/5bf94447f57db989f9df5b6682a7fdf6 |
| 2020-10-04 00:24:02 | → | fendor__ joins (~fendor@178.165.130.169.wireless.dyn.drei.com) |
| 2020-10-04 00:24:39 | <dsal> | cohn: I just use stack, tbh. But stack will make your cabal file for you. |
| 2020-10-04 00:25:16 | <dsal> | OmegaDoug: Why would you expect the latter? |
| 2020-10-04 00:25:42 | <dsal> | Er, *not* expect the latter. I think you're looking at different things. |
| 2020-10-04 00:26:36 | × | fendor_ quits (~fendor@91.141.0.198.wireless.dyn.drei.com) (Ping timeout: 260 seconds) |
| 2020-10-04 00:26:37 | <OmegaDoug> | dsal, I think I'm making a simple mistake and didn't encode it. |
| 2020-10-04 00:26:53 | <OmegaDoug> | I think I'm just printing the output directly. |
| 2020-10-04 00:27:15 | <dsal> | You're using the Show instance, which isn't related to JSON (it's not even valid JSON). |
| 2020-10-04 00:27:17 | <OmegaDoug> | printing the type as serialized by Show, not as serialized by Aeson |
| 2020-10-04 00:27:29 | <OmegaDoug> | Yeah, you beat me to it. ;) |
| 2020-10-04 00:27:50 | <dsal> | But you also don't want "drop 1" here. |
| 2020-10-04 00:28:03 | × | ech quits (~user@gateway/tor-sasl/ech) (Ping timeout: 240 seconds) |
| 2020-10-04 00:28:13 | × | hiroaki quits (~hiroaki@ip4d176049.dynamic.kabel-deutschland.de) (Ping timeout: 260 seconds) |
| 2020-10-04 00:28:23 | <dsal> | `dropWhile (== '_')` would be safer, unless you prefix all your fields with `_` (which is common in lens code, anyway) |
| 2020-10-04 00:29:36 | <OmegaDoug> | I agree 100%. But when I was mistakenly using "Show" instead of "toJson" I wanted to use a function which should have been guaranteed to work. I'll switch back to dropWhile once I have it working. |
| 2020-10-04 00:30:01 | → | ech joins (~user@gateway/tor-sasl/ech) |
| 2020-10-04 00:30:22 | × | mozzarella quits (~sam@unaffiliated/sam113101) (Ping timeout: 265 seconds) |
| 2020-10-04 00:30:27 | hackage | immortal-worker 0.1.0.0 - Create worker threads that logs exceptions and restarts. https://hackage.haskell.org/package/immortal-worker-0.1.0.0 (NCrashed) |
| 2020-10-04 00:31:16 | <OmegaDoug> | dsal, it's working perfectly now. Thanks for the help. |
| 2020-10-04 00:31:51 | <dsal> | Yeah. I've spent a bunch of time in weird bits of aeson |
| 2020-10-04 00:32:34 | × | carlomagno1 quits (~cararell@inet-hqmc02-o.oracle.com) (Ping timeout: 256 seconds) |
| 2020-10-04 00:32:41 | → | thir joins (~thir@p200300f27f0fc60004d129737887aa72.dip0.t-ipconnect.de) |
| 2020-10-04 00:34:05 | → | mozzarella joins (~sam@unaffiliated/sam113101) |
| 2020-10-04 00:36:57 | × | thir quits (~thir@p200300f27f0fc60004d129737887aa72.dip0.t-ipconnect.de) (Ping timeout: 260 seconds) |
| 2020-10-04 00:37:53 | <d34df00d> | dsal: yeah, xeno is super fast, modulo a space leak in their `fold` abstraction. |
| 2020-10-04 00:38:00 | <d34df00d> | (modify instead of modify'? srsly?) |
| 2020-10-04 00:38:08 | <d34df00d> | Thanks for pointing me to that! |
| 2020-10-04 00:38:14 | <OmegaDoug> | I was looking through https://artyom.me/aeson and it's a library with a large surface area. I'll be curious to see how it is to work with compared with some of the JSON libraries I regularly use at work going forward. |
| 2020-10-04 00:38:29 | <dsal> | d34df00d: Cool. Yeah, nobody uses xml, so it's not surprising it has bad parts. heh |
| 2020-10-04 00:39:21 | <OmegaDoug> | We use XML a fair bit. We favour JSON, but XML is hard to escape. |
| 2020-10-04 00:39:33 | <dsal> | < |
| 2020-10-04 00:40:24 | <dsal> | aeson + lens is pretty magical. Advent of code 2015 had a problem where you had to calculate the sum of all of the numbers in an arbitrary xml document. It's like, 40 characters of code. |
| 2020-10-04 00:42:19 | → | lemmih_ joins (~lemmih@218.186.157.57) |
| 2020-10-04 00:42:25 | × | ddellacosta quits (~dd@86.106.121.168) (Ping timeout: 240 seconds) |
| 2020-10-04 00:44:25 | × | lemmih quits (~lemmih@2406:3003:2072:44:640b:57cc:705a:e759) (Ping timeout: 240 seconds) |
| 2020-10-04 00:45:03 | <cohn> | dsal: I'm just trying to make a sandbox. Looks like I can just run `stack init` but I don't see where to plug in the package names I want to use in stack.yaml |
| 2020-10-04 00:45:43 | <dsal> | Oh. Now I'm curious how you've been building stuff. heh |
| 2020-10-04 00:46:26 | → | snakemasterflex joins (~snakemast@213.100.206.23) |
| 2020-10-04 00:47:02 | <dsal> | cohn: I have a template I use when starting projects. Here's an example of what that might look like: stack new awesomeproject https://gist.githubusercontent.com/dustin/e1a519e6d699ceb04c7542afe0282d56/raw/8066c389ff14799bddbb9278c5d986c20ed6d4b9/mytemplate.hsfiles |
| 2020-10-04 00:47:17 | → | nbloomf joins (~nbloomf@2600:1700:83e0:1f40:9dc0:c910:ee4d:fcdf) |
| 2020-10-04 00:47:35 | <dsal> | (that's my default template, so I just do 'stack new awesomeproject' and start running stuff) |
| 2020-10-04 00:47:48 | <cohn> | nice! thanks |
| 2020-10-04 00:47:52 | <dsal> | Packages don't go in stack.yaml, but in package.yaml |
| 2020-10-04 00:48:15 | <dsal> | I don't have a lot of default deps other than for tests. |
| 2020-10-04 00:48:18 | <cohn> | I created a package.yaml but when I run `stack ghci`, it doesn't install anything |
| 2020-10-04 00:48:51 | <dsal> | It shouldn't "install" anything. It's going to grab deps for whatever it's making a repl for. |
| 2020-10-04 00:48:56 | <dsal> | e.g. try that in this project: https://github.com/dustin/gopro/blob/master/package.yaml :) |
| 2020-10-04 00:49:02 | <cohn> | ok |
| 2020-10-04 00:49:03 | × | nbloomf quits (~nbloomf@2600:1700:83e0:1f40:9dc0:c910:ee4d:fcdf) (Client Quit) |
| 2020-10-04 00:49:30 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-10-04 00:49:51 | <dsal> | (don't actually try that in that project -- it uses half of hackage) |
| 2020-10-04 00:50:07 | <cohn> | yea, I noticed... yeesh! :D |
| 2020-10-04 00:51:20 | × | snakemasterflex quits (~snakemast@213.100.206.23) (Ping timeout: 260 seconds) |
| 2020-10-04 00:51:28 | → | nbloomf joins (~nbloomf@2600:1700:83e0:1f40:7c32:dfd5:ea25:990f) |
| 2020-10-04 00:52:58 | <cohn> | hmm. still nothing. |
| 2020-10-04 00:53:55 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 240 seconds) |
| 2020-10-04 00:54:35 | <cohn> | ah, fixed it! I had to comment out the "packages: []" line in stack.yaml |
| 2020-10-04 00:55:11 | <cohn> | suhweeeet |
| 2020-10-04 00:56:01 | → | shortdudey1231 joins (~shortdude@178.162.204.214) |
| 2020-10-04 00:56:28 | <cohn> | dsal: thanks yet again! You should probably start charging for support. hehe |
| 2020-10-04 00:56:47 | × | xff0x quits (~fox@2001:1a81:528f:c400:e801:3cdf:9d3a:43d8) (Ping timeout: 260 seconds) |
| 2020-10-04 00:57:37 | → | xff0x joins (~fox@2001:1a81:528f:c400:e12b:e4ce:eff2:a3d5) |
All times are in UTC.