2025/03/13

Newest at the top

2025-03-13 14:02:10 +0100hsw(~hsw@112-104-12-126.adsl.dynamic.seed.net.tw) hsw
2025-03-13 14:01:27 +0100weary-traveler(~user@user/user363627) user363627
2025-03-13 14:00:32 +0100kaskal(~kaskal@84-115-231-2.cable.dynamic.surfer.at) kaskal
2025-03-13 14:00:08 +0100kaskal(~kaskal@2a02:8388:15bf:c200:7418:4394:582:ede) (Quit: ZNC - https://znc.in)
2025-03-13 13:57:51 +0100ystael(~ystael@user/ystael) ystael
2025-03-13 13:57:32 +0100CiaoSen(~Jura@2a02:8071:64e1:7180::ac59) CiaoSen
2025-03-13 13:56:12 +0100sprotte24(~sprotte24@p200300d16f0b61000c042d391325af51.dip0.t-ipconnect.de)
2025-03-13 13:47:09 +0100zungi(~tory@user/andrewchawk) andrewchawk
2025-03-13 13:46:35 +0100yegorc(~yegorc@user/yegorc) yegorc
2025-03-13 13:42:12 +0100zungi(~tory@user/andrewchawk) (Ping timeout: 264 seconds)
2025-03-13 13:41:14 +0100alfiee(~alfiee@user/alfiee) (Ping timeout: 260 seconds)
2025-03-13 13:36:37 +0100alfiee(~alfiee@user/alfiee) alfiee
2025-03-13 13:32:08 +0100weary-traveler(~user@user/user363627) (Remote host closed the connection)
2025-03-13 13:27:04 +0100 <dminuoso> (Well, make it a newtype of course)
2025-03-13 13:26:54 +0100 <dminuoso> Which you could even use in a pinch
2025-03-13 13:26:35 +0100 <dminuoso> Though even if you cant find the API bits, you can just conjure some `data Decoder a = Decoder (Value -> Parser a)` (and equivalently for ToJSON)
2025-03-13 13:23:26 +0100 <dminuoso> But sure
2025-03-13 13:23:18 +0100 <dminuoso> (Or whether you have a performance constraint)
2025-03-13 13:23:13 +0100 <dminuoso> Depends on what is more comfortable.
2025-03-13 13:22:54 +0100 <tomsmeding> also I guess (from the docs) that one would rather use Encoding instead of Value?
2025-03-13 13:22:39 +0100 <dminuoso> The API is there, just not easily found/documented.
2025-03-13 13:22:31 +0100 <dminuoso> Oh yes, the documentation is not clear. Especially at the border where you need to turn this Value into a Text or vice versa.
2025-03-13 13:22:26 +0100 <tomsmeding> and hence other libraries are going to expect you to have used the instance style
2025-03-13 13:22:07 +0100 <tomsmeding> the documentation rather heavily steers you towards writing instances, though
2025-03-13 13:21:48 +0100 <tomsmeding> right
2025-03-13 13:21:40 +0100 <dminuoso> Or well, you can reroll them with minimal effort.
2025-03-13 13:21:01 +0100 <dminuoso> Most of them are usable without typeclasses.
2025-03-13 13:20:48 +0100 <tomsmeding> but then you miss out on the combinators that aeson provides in 'Parser'
2025-03-13 13:20:30 +0100 <dminuoso> What do you mean by "manually"?
2025-03-13 13:20:23 +0100 <tomsmeding> and manually parse it from a Value
2025-03-13 13:20:20 +0100 <tomsmeding> right, you can manually turn the thing into a Value, of course
2025-03-13 13:20:17 +0100 <dminuoso> I feel like this is a strange blindness issue.
2025-03-13 13:20:04 +0100 <dminuoso> `turnMyThingToJSON :: Thing -> Value`
2025-03-13 13:20:00 +0100 <tomsmeding> you can only use it on types that implement the class anyway?
2025-03-13 13:19:51 +0100 <dminuoso> Yes, so?
2025-03-13 13:19:41 +0100 <tomsmeding> dminuoso: toJSON is a method of ToJSON.
2025-03-13 13:19:12 +0100 <dminuoso> tomsmeding: `toJSON :: YourThing -> Value` - you do not have to attach this to a typeclass for this to work.
2025-03-13 13:19:10 +0100 <tomsmeding> you can even have only one newtype, and give it a phantom parameter that indicates the particular (de)serialisation you want ;)
2025-03-13 13:18:50 +0100 <tomsmeding> especially if some external dependency requires you to use the classes, use newtype wrappers
2025-03-13 13:18:18 +0100igemnace(~igemnace@user/igemnace) igemnace
2025-03-13 13:17:50 +0100__monty__(~toonn@user/toonn) toonn
2025-03-13 13:17:47 +0100 <Square2> dminuoso, what do you suggest instead? I use the OpenApi dependency which seems to require me to use Aeson instances.
2025-03-13 13:17:38 +0100 <tomsmeding> dminuoso: what to do instead?
2025-03-13 13:17:17 +0100df(~ben@justworks.xyz)
2025-03-13 13:17:02 +0100 <dminuoso> They are a rather poor fit for de/-serialization precisely for reasons like you just encountered.
2025-03-13 13:16:46 +0100 <dminuoso> Just dont use typeclass machinery.
2025-03-13 13:16:44 +0100df(~ben@justworks.xyz) (Ping timeout: 260 seconds)
2025-03-13 13:16:38 +0100 <dminuoso> Square2: You are not forced to use FromJSON/ToJSON
2025-03-13 13:16:35 +0100 <tomsmeding> this is what makes the Data.Set / Data.Map API work, for example: if you could pass the same Map between different modules with different Ord instances on the key in scope, you'll severly break the internal invariants of the Map data structure
2025-03-13 13:16:21 +0100 <Square2> Ah ok. I thought it could work with careful arrangement of things, but I could see it becoming real troublesome