Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→
Page 1 .. 610 611 612 613 614 615 616 617 618 619 620 .. 5022
502,152 events total
2020-10-13 11:13:13 <merijn> tomsmeding: I don't think Chris would mind, but you could always ping him over email and ask
2020-10-13 11:13:13 <dminuoso> Uniaika: The interface is usually like this:
2020-10-13 11:13:18 <fendor> Uniaika, Then you would need: `parseJSON obj = withObject "TopLevel Object" $ \v -> Field1 <$> v .: "field1" <|> Field2 <$> v .: "field2"`
2020-10-13 11:13:36 <dminuoso> Uniaika: withObject "foo" $ \o -> F <$> o .: "some" <*> o .: "other"
2020-10-13 11:13:41 guest35 joins (d537f42e@213.55.244.46)
2020-10-13 11:13:58 mmohammadi981266 joins (~mmohammad@188.210.103.147)
2020-10-13 11:14:10 <dminuoso> Or, as I prefer, with RecordWildcards:
2020-10-13 11:14:27 × mmohammadi981266 quits (~mmohammad@188.210.103.147) (Client Quit)
2020-10-13 11:14:43 <dminuoso> withObject "foo" $ \o -> do { field1 <- o .: "field1"; field2 <- o .: "field2"; pure F{..} }
2020-10-13 11:14:43 × chkno quits (~chkno@75-7-2-127.lightspeed.sntcca.sbcglobal.net) (Read error: Connection reset by peer)
2020-10-13 11:14:47 <fendor> Personally, I found my library to go now is aeson-combinators. Json decoders and encoders is one thing elm got right
2020-10-13 11:15:09 chkno joins (~chkno@75-7-2-127.lightspeed.sntcca.sbcglobal.net)
2020-10-13 11:15:16 <cpressey> May I humbly propose replacing 'https://gist.github.com/' in the topic of this channel with 'https://paste.tomsmeding.com/'? :)
2020-10-13 11:15:23 <dminuoso> fendor: waargonaut addresses most issues well
2020-10-13 11:15:34 <dminuoso> it has a much better and flexible interface
2020-10-13 11:15:42 <Uniaika> dminuoso: but wouldn't that mean that the expected JSON has this "foo" sub-object then?
2020-10-13 11:15:42 × chkno quits (~chkno@75-7-2-127.lightspeed.sntcca.sbcglobal.net) (Read error: Connection reset by peer)
2020-10-13 11:15:59 <dminuoso> Uniaika: No, that's just a name that is used for debugging
2020-10-13 11:16:13 <dminuoso> Uniaika: So when the parser fail, it will call the object (it was looking for) "foo"
2020-10-13 11:16:13 × nados quits (~dan@107-190-41-58.cpe.teksavvy.com) (Read error: Connection reset by peer)
2020-10-13 11:16:23 <fendor> dminuoso, too complex for my taste
2020-10-13 11:16:33 <dminuoso> fendor: Dunno, I find it rather simple.
2020-10-13 11:16:38 × p8m quits (p8m@gateway/vpn/protonvpn/p8m) (Ping timeout: 272 seconds)
2020-10-13 11:16:46 nados joins (~dan@107-190-41-58.cpe.teksavvy.com)
2020-10-13 11:16:54 <dminuoso> Uniaika: https://hackage.haskell.org/package/aeson-1.5.4.1/docs/src/Data.Aeson.Types.FromJSON.html#withObject
2020-10-13 11:17:13 <merijn> dminuoso: waargonaut's API is a Lovecraftian mess I wouldn't wish upon my worst enemy
2020-10-13 11:17:41 p8m joins (p8m@gateway/vpn/protonvpn/p8m)
2020-10-13 11:18:02 raehik joins (~raehik@cpc96984-rdng25-2-0-cust109.15-3.cable.virginm.net)
2020-10-13 11:18:25 <dminuoso> merijn: It's not any less offending than say megaparsec.
2020-10-13 11:18:48 <dminuoso> And zippers!
2020-10-13 11:19:05 <dminuoso> When you have to deal with other peoples formats, zippers are really a blessing.
2020-10-13 11:19:32 lucid_0x80 joins (~lucid_0x8@85.132.73.6)
2020-10-13 11:19:44 jollygood2 joins (~bc8165ab@217.29.117.252)
2020-10-13 11:19:49 <fendor> aeson-combinators is much less offending. But I have to admit, Currently I only have rather trivial json formats to maintain
2020-10-13 11:19:50 <dminuoso> And waargonaut handles JSON better, since it can deal with multiple "overlapping" attributes in objects
2020-10-13 11:19:54 × olligobber quits (olligobber@gateway/vpn/privateinternetaccess/olligobber) (Remote host closed the connection)
2020-10-13 11:19:59 <merijn> dminuoso: tbh, I think megaparsec has regressed *a lot* in that regard
2020-10-13 11:20:10 chkno joins (~chkno@75-7-2-127.lightspeed.sntcca.sbcglobal.net)
2020-10-13 11:20:18 <merijn> And it's a bad thing for Haskell and the ability to promote megaparsec to beginners
2020-10-13 11:21:01 <dminuoso> merijn: The rudimentary interface of waargonaut is simpler than aeson by far.
2020-10-13 11:21:04 × chkno quits (~chkno@75-7-2-127.lightspeed.sntcca.sbcglobal.net) (Read error: Connection reset by peer)
2020-10-13 11:21:42 <merijn> dminuoso: Then they need to package/document it better to hide away the clutter from the "main" user facing UI
2020-10-13 11:21:53 <dminuoso> I agree, the documentation could be improved.
2020-10-13 11:22:05 chkno joins (~chkno@75-7-2-127.lightspeed.sntcca.sbcglobal.net)
2020-10-13 11:23:07 <nshepperd> Uniaika: the top level json you're looking at there _is_ an object, that's what withObject is for
2020-10-13 11:23:15 mmohammadi981266 joins (~mmohammad@188.210.103.147)
2020-10-13 11:23:27 <nshepperd> field1 and field2 being text fields of it
2020-10-13 11:23:52 <Uniaika> nshepperd: okay, I was afraid that since I'm writing an instance for what is a secondary object, it would try and mimic that structure in the JSON, which is a flat object
2020-10-13 11:23:53 × mmohammadi981266 quits (~mmohammad@188.210.103.147) (Client Quit)
2020-10-13 11:24:23 <dminuoso> merijn: https://github.com/qfpl/waargonaut#example if you consider these examples, the ergonomics is quite good. :)
2020-10-13 11:24:57 <merijn> dminuoso: the Haddocks are just 15 pages of type gobbledy-gook, though
2020-10-13 11:24:58 hackage imm 2.0.0.0 - Execute arbitrary actions for each item from RSS/Atom feeds https://hackage.haskell.org/package/imm-2.0.0.0 (koral)
2020-10-13 11:25:50 <dminuoso> merijn: Bringing me back to my original point, we should get rid of all that JSON nonsense.
2020-10-13 11:25:57 <fendor> dminuoso, also, why are they using fromKey instead of atKey? atKey seems to be simpler
2020-10-13 11:26:07 <dminuoso> Just specify and write wire protocols, like programmers have done for the past 30 years.
2020-10-13 11:26:25 <dminuoso> a bit of `binary` works wonders
2020-10-13 11:26:28 <merijn> dminuoso: Or use dhall :)
2020-10-13 11:26:39 <dminuoso> Oh, for configuration sure.
2020-10-13 11:26:46 × lucid_0x80 quits (~lucid_0x8@85.132.73.6) (Ping timeout: 272 seconds)
2020-10-13 11:27:00 <dminuoso> For data exchange, if I had to pick a premade serialization format again, I'd go cbor.
2020-10-13 11:27:07 <merijn> but yeah, a good BNF + wire protocol >> poorly implemented shit on top of JSON
2020-10-13 11:27:25 <dminuoso> Indeed.
2020-10-13 11:27:44 <nshepperd> @hackage serialize
2020-10-13 11:27:44 <lambdabot> https://hackage.haskell.org/package/serialize
2020-10-13 11:28:06 <dminuoso> nshepperd: I think you were looking for cereal?
2020-10-13 11:28:06 <merijn> binary has pretty much obsoleted serialise, tbh
2020-10-13 11:28:12 <nshepperd> oop misspelt
2020-10-13 11:28:14 <merijn> eh, yeah cereal I mean
2020-10-13 11:28:29 <nshepperd> @hackage serialise
2020-10-13 11:28:29 <lambdabot> https://hackage.haskell.org/package/serialise
2020-10-13 11:28:34 <dminuoso> I mean, cereal was made because binary was lacking support for strict bytestrings?
2020-10-13 11:28:43 <dminuoso> binary supports both lazy and strict bytestrings now
2020-10-13 11:28:53 <dminuoso> has good support for adding contexts
2020-10-13 11:29:04 <nshepperd> serialise is cbor based, very nice imo
2020-10-13 11:30:26 <dminuoso> nshepperd: serialise seems great if you want to do data exchange between two haskell systems over the network.
2020-10-13 11:30:52 <merijn> template-haskell versions are tied to specific GHCs, right?
2020-10-13 11:31:08 <dminuoso> https://hackage.haskell.org/package/template-haskell
2020-10-13 11:31:13 <dminuoso> merijn: Judging from the bounds, Id say now
2020-10-13 11:31:16 <dminuoso> *no
2020-10-13 11:31:21 <dminuoso> base (>=4.11 && <4.15), ghc-boot-th (==8.10.1), ghc-prim, pretty (==1.1.*) [details]
2020-10-13 11:31:25 <nshepperd> i also use it for serialising cached stuff to disk between runs of the same program
2020-10-13 11:33:06 × chele quits (~chele@5.53.222.202) (Ping timeout: 272 seconds)
2020-10-13 11:33:08 × Tario quits (~Tario@201.192.165.173) (Ping timeout: 258 seconds)
2020-10-13 11:33:19 snakemas1 joins (~snakemast@213.100.206.23)
2020-10-13 11:33:25 Tario joins (~Tario@201.192.165.173)
2020-10-13 11:33:42 <tomjaguarpaw> I can't help thinking that what's important is the logical structure of the wire format rather than its concrete structure.
2020-10-13 11:34:56 <tomsmeding> merijn: https://github.com/haskellweekly/haskellweekly/pull/52
2020-10-13 11:37:01 machinedgod joins (~machinedg@24.105.81.50)
2020-10-13 11:37:06 polyrain joins (~polyrain@2001:8003:e501:6901:8a4:c02:960d:e633)
2020-10-13 11:38:17 seanvert joins (~user@177.84.244.242)
2020-10-13 11:38:46 alp joins (~alp@2a01:e0a:58b:4920:2586:865a:4e94:a66b)
2020-10-13 11:39:25 bahamas joins (~lucian@unaffiliated/bahamas)
2020-10-13 11:39:32 cfricke joins (~cfricke@unaffiliated/cfricke)
2020-10-13 11:41:51 <kuribas> Uniaika: don't you need (.:?) ?
2020-10-13 11:42:07 <kuribas> Uniaika: it returns a Maybe for a field that can be possibly null.
2020-10-13 11:42:23 <Uniaika> I found a way, actually
2020-10-13 11:42:50 <Uniaika> solving the issue upstream, and not deriving the instance for the type, but taking care of serde in the upstream type
2020-10-13 11:43:00 <Uniaika> (it does work)
2020-10-13 11:43:02 <kuribas> that's even better :)
2020-10-13 11:43:16 <Uniaika> thank you all for your time, I love you all, you're incredible <3

All times are in UTC.