Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,803,946 events total
2021-08-02 07:31:29 <mastarija> Yes, it is.
2021-08-02 07:31:37 geekosaur joins (~geekosaur@xmonad/geekosaur)
2021-08-02 07:32:19 <mastarija> I mean, everything checks out, it's just that "empty" that's a thorn in my eyes, and there's no way to introduce it through my DSL other than explicitly writing "empty" somewhere in the code
2021-08-02 07:32:37 <mastarija> Could I use custom error messages somehow in that case?
2021-08-02 07:32:57 <mastarija> So that compiler warns the user in advance if he typed empty instead of mempty?
2021-08-02 07:32:58 <dibblego> you might want to show the example
2021-08-02 07:33:20 <mastarija> data Wrong e = Neutral | Inert e | Wrong e
2021-08-02 07:33:31 <mastarija> My error aggregation type
2021-08-02 07:33:48 <mastarija> Neutral is added purely because of empty
2021-08-02 07:33:53 <dibblego> FYI, that's iso to data Wrong e = Neutral | Blah e Bool
2021-08-02 07:34:10 <mastarija> Yes
2021-08-02 07:34:26 <dibblego> my opinion: if there is a bug because of typing the wrong thing in a nominal system -> use parametricity more
2021-08-02 07:34:42 <mastarija> Ideally, it would be data Wrong e = Inert e | Wrong e
2021-08-02 07:34:53 <dibblego> well do that as well if it helps
2021-08-02 07:35:04 <mastarija> dibblego, not sure what you mean by parametricity
2021-08-02 07:35:26 <dibblego> x :: Alternative f => f a; x = mempty -- fails to compile
2021-08-02 07:35:38 kuribas joins (~user@ptr-25vy0i94rzok8s66yz2.18120a2.ip6.access.telenet.be)
2021-08-02 07:36:09 <kuribas> would it be possible to get C-like performance for dealing with binary data formats?
2021-08-02 07:36:15 <kuribas> In C I can just cast a buffer to a datatype.
2021-08-02 07:36:26 <euouae> There's unboxed types
2021-08-02 07:36:44 <kuribas> However, in haskell instead of just deserialising, I could take a strict bytestring and use accessor functions.
2021-08-02 07:36:58 mastarija_ joins (~mastarija@31.217.8.174)
2021-08-02 07:37:14 <mastarija_> why does this nickserv keep changing my username?
2021-08-02 07:37:21 × timCF quits (~timCF@200-149-20-81.sta.estpak.ee) (Quit: leaving)
2021-08-02 07:37:28 <euouae> You're dropping your connection mastarija_
2021-08-02 07:37:42 <mastarija_> Hm... didn't used to happen.
2021-08-02 07:38:00 <euouae> kuribas: You can use GHCs unboxed types, wouldn't that be what you need in terms of performance?
2021-08-02 07:38:20 <kuribas> euouae: the bytestring is irregular, like, not a list of integers, but a index, different regions, etc...
2021-08-02 07:38:33 <kuribas> like a binary file format...
2021-08-02 07:39:12 <euouae> It can be an array of unboxed bytes which you can then interpret as you'd like
2021-08-02 07:39:28 <kuribas> yes, something like that...
2021-08-02 07:40:34 × mastarija quits (~mastarija@31.217.8.174) (Ping timeout: 272 seconds)
2021-08-02 07:41:43 <euouae> You need to benchmark and see whether you need that
2021-08-02 07:41:53 <euouae> Have you determined that your code is slow as is?
2021-08-02 07:41:59 <nshepperd> use Storable and hope the memcpys get optimised away?
2021-08-02 07:42:15 <kuribas> hmm, bytestring doesn't have O(1) conversion from C Ptr?
2021-08-02 07:43:14 <kuribas> Maybe I need Vector.Storable.Vector Word8 then...
2021-08-02 07:45:18 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-08-02 07:46:21 × mastarija_ quits (~mastarija@31.217.8.174) (Quit: Leaving)
2021-08-02 07:47:03 chele joins (~chele@user/chele)
2021-08-02 07:47:28 <euouae> is it possible to work with Haskell offline?
2021-08-02 07:47:40 <dminuoso> Why shouldn't it?
2021-08-02 07:47:49 <euouae> I.e. have cabal and/or stack use the cached modules
2021-08-02 07:48:04 <euouae> and also access the docs from haddock for base?
2021-08-02 07:48:13 <maerwald[m]> Cabal has an `--offline` switch
2021-08-02 07:48:18 <euouae> Nice
2021-08-02 07:48:27 <kuribas> ah, unsafeUseAsCString is O(1)
2021-08-02 07:48:29 <euouae> Ok that probably does it. Thanks
2021-08-02 07:48:30 <dminuoso> Also, davean has build a thing while they were offline for a prolonged time.
2021-08-02 07:48:33 <maerwald[m]> Haddock db will need to be built afair
2021-08-02 07:48:37 <dminuoso> But I dont recall the name of that project
2021-08-02 07:49:42 <euouae> Alright, g2g, thank you for the help.
2021-08-02 07:49:45 × euouae quits (~euouae@user/euouae) (Quit: Client closed)
2021-08-02 07:50:32 <merijn> Most extreme scenario you can just host a local mirror of Hackage :p
2021-08-02 07:51:19 <dminuoso> Yeah, and davean build something akin to that
2021-08-02 07:51:35 <dminuoso> But hackage is quite a beast that cant just be run. It's very annoying
2021-08-02 07:55:53 mastarija joins (~mastarija@31.217.8.174)
2021-08-02 07:57:38 <maerwald[m]> This should be made easier
2021-08-02 07:58:18 × gambpang quits (~ian@207.181.230.156) (Ping timeout: 272 seconds)
2021-08-02 07:58:34 gambpang joins (~ian@207.181.230.156)
2021-08-02 07:58:46 dschrempf joins (~dominik@070-207.dynamic.dsl.fonira.net)
2021-08-02 08:00:25 <kuribas> hmm, maybe I can use GADTs to get safe indexes. For example data MyFields a where Field1 :: Field Int8; Field2 :: Field Word16, then some magic to calculate offsets...
2021-08-02 08:03:58 <kuribas> better than manually calculating offsets...
2021-08-02 08:05:35 <kuribas> Maybe a TH function that creates a function "readMyField :: ByteString -> MyFields a -> a"
2021-08-02 08:05:55 <kuribas> (or generics, but that doesn't seem to work with GADTs).
2021-08-02 08:06:05 hendursa1 joins (~weechat@user/hendursaga)
2021-08-02 08:08:26 × hendursaga quits (~weechat@user/hendursaga) (Ping timeout: 244 seconds)
2021-08-02 08:10:22 <kuribas> of course the idea is that this becomes inlined, and reduced to a single indexed bytestring read.
2021-08-02 08:12:39 <merijn> kuribas: Why not use, like, binary?
2021-08-02 08:12:57 <kuribas> merijn: because that implies copying.
2021-08-02 08:13:33 <merijn> How so?
2021-08-02 08:14:08 <kuribas> merijn: because I need to deserialize the whole thing, no?
2021-08-02 08:14:20 <kuribas> merijn: where I want only a single field, for example.
2021-08-02 08:14:23 <merijn> It Depends (TM)
2021-08-02 08:14:45 <merijn> tbh, if you want to index specific byte locations it sounds like you just want Storable
2021-08-02 08:14:53 × earthy quits (~arthurvl@2001:984:275b:1:ba27:ebff:fea0:40b0) (Ping timeout: 255 seconds)
2021-08-02 08:15:27 <kuribas> merijn: that doesn't solve the problem of finding a single field, does it?
2021-08-02 08:16:13 <merijn> I think I'm missing context here
2021-08-02 08:16:47 × aegon quits (~mike@174.127.249.180) (Quit: leaving)
2021-08-02 08:17:17 <kuribas> merijn: in my example above, say I want Field2, not Field1
2021-08-02 08:17:22 × geekosaur quits (~geekosaur@xmonad/geekosaur) (Remote host closed the connection)
2021-08-02 08:17:26 zeenk joins (~zeenk@2a02:2f04:a211:a800:553b:3cb0:5ea1:7e83)
2021-08-02 08:17:47 geekosaur joins (~geekosaur@xmonad/geekosaur)
2021-08-02 08:17:50 <kuribas> here it's only two fields, but in reality it may be a big buffer with several indirections.
2021-08-02 08:18:26 <merijn> there is no example above
2021-08-02 08:18:34 × dschrempf quits (~dominik@070-207.dynamic.dsl.fonira.net) (Ping timeout: 272 seconds)
2021-08-02 08:18:45 <merijn> There's just a vague handwave of a GADT with no relation to any specific memory layout/whatever
2021-08-02 08:20:00 <kuribas> merijn: the layout is the order of the data type.
2021-08-02 08:21:06 × johnw quits (~johnw@76-234-69-149.lightspeed.frokca.sbcglobal.net) (Quit: ZNC - http://znc.in)
2021-08-02 08:21:12 <kuribas> So struct MyFields { char field1; unsigned short field2 }.
2021-08-02 08:22:31 <merijn> You just said you had indirections, though, so that can't be right
2021-08-02 08:23:05 <kuribas> not in this example
2021-08-02 08:25:19 <kuribas> merijn: even without indirection, binary will not help
2021-08-02 08:25:22 <kuribas> or Storable
2021-08-02 08:25:58 <merijn> How will Storable not help?
2021-08-02 08:26:50 michalz joins (~michalz@185.246.204.40)
2021-08-02 08:28:37 <merijn> In fact, storable is really the *only* way to arbitrary indexing
2021-08-02 08:29:20 <dminuoso> Storable has some really odd UX problems. :(
2021-08-02 08:30:23 <merijn> hmm?
2021-08-02 08:30:23 <kuribas> merijn: show me how how to get field2 using storable, without deserializing the whole thing?

All times are in UTC.