Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-04-30 13:44:41 frozenErebus joins (~frozenEre@37.231.244.249)
2021-04-30 13:44:43 <tomsmeding> also the outer json isn't valid, it's missing quotes around the "string"
2021-04-30 13:45:11 × ddellacosta quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Remote host closed the connection)
2021-04-30 13:45:15 × idhugo quits (~idhugo@80-62-116-231-mobile.dk.customer.tdc.net) (Ping timeout: 268 seconds)
2021-04-30 13:45:31 <tomsmeding> if you make that valid, then I guess you can use aeson to decode to a ByteString (or a String, I guess), and then pass that again to aeson to decode as a Book
2021-04-30 13:46:09 <biglama> So you can't do it a single pass ?
2021-04-30 13:47:44 <tomsmeding> no
2021-04-30 13:48:03 <tomsmeding> having double-encoded json is not the common case :p
2021-04-30 13:48:33 <tomsmeding> oh wait that nested json contains _more_ nested json inside
2021-04-30 13:48:42 <tomsmeding> holy crap who designed that API
2021-04-30 13:48:56 <biglama> I can't say :/
2021-04-30 13:49:03 <tomsmeding> no matter :p
2021-04-30 13:49:42 <biglama> Let me get the json straight, I'm lost in escaping quotes
2021-04-30 13:50:10 <tomsmeding> what you posted here is a valid json string that, when decoded, produces something that you can parse as json again
2021-04-30 13:50:27 <tomsmeding> you pasted that directly in your source file, but now suddenly the outer quotes are taken to be a _haskell_ string
2021-04-30 13:50:50 <tomsmeding> I suggest putting the API response in a file and reading that in your test program :p
2021-04-30 13:51:48 ddellaco_ joins (~ddellacos@ool-44c73afa.dyn.optonline.net)
2021-04-30 13:52:14 × plutoniix quits (~q@node-upe.pool-125-24.dynamic.totinternet.net) (Ping timeout: 265 seconds)
2021-04-30 13:52:39 <biglama> Yeah, what I posted is what the API is sending
2021-04-30 13:53:10 <biglama> So I need an intermediary data type (reading the string as such) and a final datatype with parsing just nested json ?
2021-04-30 13:53:41 <tomsmeding> where that intermediary data type is a string, yes
2021-04-30 13:53:47 <tomsmeding> perhaps it should be a bytestring for aeson, not sure
2021-04-30 13:54:12 <biglama> Bytestring, right
2021-04-30 13:54:53 <biglama> And you can't call decode when instancing FromJSON (so decoding in a decode ... :p) ?
2021-04-30 13:57:11 <tomsmeding> why not?
2021-04-30 13:57:27 × ukari quits (~ukari@unaffiliated/ukari) (Remote host closed the connection)
2021-04-30 13:57:28 <tomsmeding> well depends on how FromJSON works I guess
2021-04-30 13:57:43 <geekosaur> pretty sure it relies on being able to do just that
2021-04-30 13:57:52 plutoniix joins (~q@node-upe.pool-125-24.dynamic.totinternet.net)
2021-04-30 13:58:03 × stef204 quits (~stef204@unaffiliated/stef-204/x-384198) (Quit: WeeChat 3.1)
2021-04-30 13:58:14 ukari joins (~ukari@unaffiliated/ukari)
2021-04-30 13:58:16 <geekosaur> to e.g. decode the value part of an Object which is itself an Object
2021-04-30 13:58:31 <tomsmeding> perhaps you can write a general function, 'doubleDecode :: FromJSON a => ByteString -> Maybe a', which first decodes as ByteString and then uses the FromJSON instance to decode as an 'a'
2021-04-30 13:58:40 idhugo joins (~idhugo@80-62-116-231-mobile.dk.customer.tdc.net)
2021-04-30 13:59:09 × ddellaco_ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Remote host closed the connection)
2021-04-30 14:00:07 ddellaco_ joins (~ddellacos@ool-44c73afa.dyn.optonline.net)
2021-04-30 14:00:14 × jgt quits (~jgt@46.154.25.63) (Remote host closed the connection)
2021-04-30 14:01:10 <tomsmeding> doubleDecode bs = (decode bs :: Maybe ByteString) >>= decode
2021-04-30 14:01:26 <tomsmeding> the type annotation shouldn't even be necessary
2021-04-30 14:01:45 jgt joins (~jgt@46.154.68.68)
2021-04-30 14:01:46 Pickchea joins (~private@unaffiliated/pickchea)
2021-04-30 14:01:55 <tomsmeding> 'doubleDecode = decode >=> decode' using (>=>) from Control.Monad
2021-04-30 14:02:13 tomsmeding likes that expression
2021-04-30 14:02:58 × idhugo quits (~idhugo@80-62-116-231-mobile.dk.customer.tdc.net) (Ping timeout: 252 seconds)
2021-04-30 14:03:11 <biglama> tomsmeding: I've tried to do it in the instance like this : https://paste.tomsmeding.com/6dkT4jXG
2021-04-30 14:04:08 × ddellaco_ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Ping timeout: 246 seconds)
2021-04-30 14:04:50 <biglama> It would work even if there are other fields ? Only one of them has the nested escaped... thing
2021-04-30 14:05:02 × jespada quits (~jespada@87.74.37.248) (Quit: Leaving)
2021-04-30 14:05:28 tomsmeding is not familiar enough with aeson's parser language to answer that
2021-04-30 14:05:46 <geekosaur> you would only write an explicit instance for that one field and take the (Generics) default for the rest, as I understand it
2021-04-30 14:06:49 × stree quits (~stree@68.36.8.116) (Ping timeout: 252 seconds)
2021-04-30 14:06:56 × olligobber quits (olligobber@gateway/vpn/privateinternetaccess/olligobber) (Ping timeout: 246 seconds)
2021-04-30 14:10:12 alx741 joins (~alx741@181.196.68.89)
2021-04-30 14:12:35 <biglama> That's what I've been trying to do, but without success
2021-04-30 14:14:41 ddellacosta joins (ddellacost@gateway/vpn/mullvad/ddellacosta)
2021-04-30 14:14:51 × malumore_ quits (~malumore@151.62.115.54) (Ping timeout: 268 seconds)
2021-04-30 14:15:37 malumore_ joins (~malumore@151.62.115.54)
2021-04-30 14:16:04 enthropy joins (~aavogt@135-23-166-92.cpe.pppoe.ca)
2021-04-30 14:19:28 × ddellacosta quits (ddellacost@gateway/vpn/mullvad/ddellacosta) (Ping timeout: 252 seconds)
2021-04-30 14:19:33 stree joins (~stree@68.36.8.116)
2021-04-30 14:19:50 × jgt quits (~jgt@46.154.68.68) (Quit: WeeChat 2.9)
2021-04-30 14:20:56 × elfets quits (~elfets@ip-37-201-23-96.hsi13.unitymediagroup.de) (Ping timeout: 260 seconds)
2021-04-30 14:24:02 xkapastel joins (uid17782@gateway/web/irccloud.com/x-bodjmmiexpfrqdom)
2021-04-30 14:27:34 star_cloud joins (~star_clou@ec2-34-220-44-120.us-west-2.compute.amazonaws.com)
2021-04-30 14:29:41 × nut quits (~gtk@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) (Ping timeout: 260 seconds)
2021-04-30 14:30:10 Sheilong joins (uid293653@gateway/web/irccloud.com/x-zoclupkfjvlkftdp)
2021-04-30 14:30:18 pringlescan joins (uid192736@gateway/web/irccloud.com/x-lenvtbpxunzhzodb)
2021-04-30 14:31:42 <biglama> Thanks guys, i'll try my luck on stack overflow :)
2021-04-30 14:33:32 × vilpan quits (~0@212.117.1.172) (Ping timeout: 240 seconds)
2021-04-30 14:33:48 × frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 265 seconds)
2021-04-30 14:34:54 × dmytrish quits (~mitra@2a02:8084:a82:d900:61fb:ae9:64fb:f0ec) (Remote host closed the connection)
2021-04-30 14:35:43 kritzefitz_ joins (~kritzefit@212.86.56.80)
2021-04-30 14:36:43 × geekosaur quits (930099da@rrcs-147-0-153-218.central.biz.rr.com) (Ping timeout: 240 seconds)
2021-04-30 14:37:11 dmytrish joins (~mitra@2a02:8084:a82:d900:1d3:5573:40ff:23bb)
2021-04-30 14:38:09 × biglama quits (~alex@static-176-165-167-17.ftth.abo.bbox.fr) (Remote host closed the connection)
2021-04-30 14:40:25 ep1ctetus joins (~epictetus@ip72-194-54-201.sb.sd.cox.net)
2021-04-30 14:43:05 slack1256 joins (~slack1256@191.113.245.191)
2021-04-30 14:43:46 Gurkenglas joins (~Gurkengla@unaffiliated/gurkenglas)
2021-04-30 14:44:39 LKoen joins (~LKoen@22.249.88.92.rev.sfr.net)
2021-04-30 14:44:50 <slack1256> Is there a way to load the test modules on `stack`?
2021-04-30 14:44:57 <slack1256> I mean for the repl
2021-04-30 14:47:03 ddellacosta joins (ddellacost@gateway/vpn/mullvad/ddellacosta)
2021-04-30 14:47:26 ddellac__ joins (~ddellacos@ool-44c73afa.dyn.optonline.net)
2021-04-30 14:47:47 × ddellac__ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Read error: Connection reset by peer)
2021-04-30 14:49:01 takuan joins (~takuan@178-116-218-225.access.telenet.be)
2021-04-30 14:49:20 ddellac__ joins (ddellacost@gateway/vpn/mullvad/ddellacosta)
2021-04-30 14:49:37 vilpan joins (~0@212.117.1.172)
2021-04-30 14:49:54 × takuan quits (~takuan@178-116-218-225.access.telenet.be) (Remote host closed the connection)
2021-04-30 14:50:28 <slack1256> Nevermind, `stack ide targets` is golden.
2021-04-30 14:51:11 × ddellacosta quits (ddellacost@gateway/vpn/mullvad/ddellacosta) (Ping timeout: 240 seconds)
2021-04-30 14:54:01 × kuribas quits (~user@ptr-25vy0i96tdwzmfpbump.18120a2.ip6.access.telenet.be) (Remote host closed the connection)
2021-04-30 14:54:19 × _bin quits (~bin@75-54-107-59.lightspeed.hstntx.sbcglobal.net) (Ping timeout: 268 seconds)
2021-04-30 14:55:41 _bin joins (~bin@2600:1700:10a1:38d0:318b:dcd9:cdc4:9ce1)
2021-04-30 14:56:20 geowiesnot joins (~user@i15-les02-ix2-87-89-181-157.sfr.lns.abo.bbox.fr)
2021-04-30 14:57:55 × dmytrish quits (~mitra@2a02:8084:a82:d900:1d3:5573:40ff:23bb) (Read error: No route to host)
2021-04-30 14:58:46 × dansho quits (~dansho@ec2-13-231-153-158.ap-northeast-1.compute.amazonaws.com) (Remote host closed the connection)
2021-04-30 14:59:13 dansho joins (~dansho@ec2-13-231-153-158.ap-northeast-1.compute.amazonaws.com)
2021-04-30 15:01:19 × _bin quits (~bin@2600:1700:10a1:38d0:318b:dcd9:cdc4:9ce1) (Ping timeout: 260 seconds)
2021-04-30 15:01:41 takuan joins (~takuan@178-116-218-225.access.telenet.be)
2021-04-30 15:02:29 dmytrish joins (~mitra@2a02:8084:a82:d900:4cc7:f0a8:8d74:1dfc)

All times are in UTC.