Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,532 events total
2021-08-27 15:08:40 ziman joins (~ziman@user/ziman)
2021-08-27 15:10:20 <ziman> hello! I have a typeclass (Serialise metadata a), where I'd like instances to depend only on `a`, i.e. make it impossible that `metadata` could affect the serialisation procedure.
2021-08-27 15:10:42 <ziman> i'd like to mark `metadata` as irrelevant in some way but is that possible in Haskell?
2021-08-27 15:10:58 <ziman> fundeps don't do what i want because i want instances to work for arbitrary `metadata` for any single `a`
2021-08-27 15:11:12 <timCF> ziman: why it's needed in class definition then?
2021-08-27 15:12:31 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Ping timeout: 250 seconds)
2021-08-27 15:13:15 <ziman> no behaviour depends on it, it is only used to express that this typeclass is not available for some `metadata`, so not all instances are universally quantified over `metadata`; some instances exist only for one `metadata` value
2021-08-27 15:15:10 <c_wraith> Well then, the type *does* affect the process, in that it's just not available for some types.
2021-08-27 15:15:37 <c_wraith> Haskell makes classes open. It's always assumed another module could add another instance
2021-08-27 15:16:18 <ziman> the typeclass contains a method called toBS, which converts the type to bytestring
2021-08-27 15:16:24 MQ-17J joins (~MQ-17J@d14-69-206-129.try.wideopenwest.com)
2021-08-27 15:16:26 <c_wraith> So the compiler has to assume the type does impact the functionality
2021-08-27 15:16:28 <ziman> i'd like to express that the result of toBS cannot depend on the metadata
2021-08-27 15:16:32 × hendursa1 quits (~weechat@user/hendursaga) (Quit: hendursa1)
2021-08-27 15:16:42 <c_wraith> But you've just said it can
2021-08-27 15:17:03 hendursaga joins (~weechat@user/hendursaga)
2021-08-27 15:17:05 × pavonia quits (~user@user/siracusa) (Quit: Bye!)
2021-08-27 15:17:05 <c_wraith> In that if the metadata type is wrong, you can't call it
2021-08-27 15:17:15 <c_wraith> that is a dependency
2021-08-27 15:17:15 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:b5b4:3a1f:2123:21ea)
2021-08-27 15:18:30 <c_wraith> Maybe you want to split the class in two? One class without the metadata type involved, one class with?
2021-08-27 15:19:09 <c_wraith> You could have the class with the metadata depend on the one without, so you'd only need to write that one in type signatures
2021-08-27 15:19:39 <ziman> hmmm
2021-08-27 15:19:40 × dsrt^ quits (~dsrt@12.16.129.111) (Ping timeout: 240 seconds)
2021-08-27 15:20:56 <hololeap> @hoogle (Maybe a, Maybe b) -> Maybe (a,b)
2021-08-27 15:20:57 <lambdabot> No results found
2021-08-27 15:21:40 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:b5b4:3a1f:2123:21ea) (Ping timeout: 240 seconds)
2021-08-27 15:21:47 <c_wraith> :t uncurry $ liftA2 (,)
2021-08-27 15:21:48 neo2 joins (~neo3@cpe-292712.ip.primehome.com)
2021-08-27 15:21:48 <lambdabot> Applicative f => (f a, f b) -> f (a, b)
2021-08-27 15:21:55 <ziman> thanks, i'll think about it
2021-08-27 15:22:12 <ziman> maybe one just can't do it in haskell
2021-08-27 15:22:34 <c_wraith> Haskell makes assumptions about instances that makes restricting them difficult
2021-08-27 15:22:58 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Ping timeout: 252 seconds)
2021-08-27 15:23:15 MQ-17J joins (~MQ-17J@d14-69-206-129.try.wideopenwest.com)
2021-08-27 15:23:55 doyougnu joins (~user@c-73-25-202-122.hsd1.or.comcast.net)
2021-08-27 15:24:31 × nilof quits (~olofs@90-227-86-119-no542.tbcn.telia.com) (Read error: Connection reset by peer)
2021-08-27 15:24:48 nilof joins (~olofs@90-227-86-119-no542.tbcn.telia.com)
2021-08-27 15:25:10 × neo1 quits (~neo3@cpe-292712.ip.primehome.com) (Ping timeout: 252 seconds)
2021-08-27 15:28:28 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 252 seconds)
2021-08-27 15:29:10 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:b5b4:3a1f:2123:21ea)
2021-08-27 15:29:18 × hannessteffenhag quits (~hannesste@ip4d14ffc8.dynamic.kabel-deutschland.de) (Ping timeout: 250 seconds)
2021-08-27 15:33:15 hexfive joins (~eric@50.35.83.177)
2021-08-27 15:34:51 glider_ is now known as glider
2021-08-27 15:39:51 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:b5b4:3a1f:2123:21ea) (Remote host closed the connection)
2021-08-27 15:40:17 × martin02 quits (~silas@141.84.69.76) (Ping timeout: 248 seconds)
2021-08-27 15:40:45 asthasr joins (~asthasr@162.210.28.151)
2021-08-27 15:41:48 raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net)
2021-08-27 15:44:47 waleee joins (~waleee@2001:9b0:216:8200:d457:9189:7843:1dbd)
2021-08-27 15:44:51 jakalx parts (~jakalx@base.jakalx.net) ()
2021-08-27 15:45:32 hannessteffenhag joins (~hannesste@ip4d14ffc8.dynamic.kabel-deutschland.de)
2021-08-27 15:46:59 jakalx joins (~jakalx@base.jakalx.net)
2021-08-27 15:47:13 × Skyfire quits (~pyon@user/pyon) (Quit: WeeChat 3.2)
2021-08-27 15:48:55 × dajoer quits (~david@user/gvx) (Quit: leaving)
2021-08-27 15:50:09 × hexfive quits (~eric@50.35.83.177) (Quit: WeeChat 3.0.1)
2021-08-27 15:50:14 argento joins (~argent0@168-227-96-26.ptr.westnet.com.ar)
2021-08-27 15:51:05 × hannessteffenhag quits (~hannesste@ip4d14ffc8.dynamic.kabel-deutschland.de) (Ping timeout: 250 seconds)
2021-08-27 15:51:36 Guest55 joins (~Guest55@188.64.207.213)
2021-08-27 15:51:44 × egoist quits (~egoist@186.235.82.117) (Quit: WeeChat 3.2)
2021-08-27 15:51:51 × hendursaga quits (~weechat@user/hendursaga) (Remote host closed the connection)
2021-08-27 15:51:52 <Guest55> hey
2021-08-27 15:52:18 hendursaga joins (~weechat@user/hendursaga)
2021-08-27 15:52:47 × lortabac quits (~lortabac@151.70.200.251) (Quit: WeeChat 2.8)
2021-08-27 15:53:00 × cheater quits (~Username@user/cheater) (Remote host closed the connection)
2021-08-27 15:53:51 <Guest55> i wanna find the longest truthiness sequence [False, False, True, True, False, True, False, False, True, True, True, True, False, False, True, True].
2021-08-27 15:54:04 <Guest55> the starting point and length of it
2021-08-27 15:54:26 <Guest55> everything i come up with looks messy. any ideas?
2021-08-27 15:55:01 <c_wraith> are you allowed to use stuff from Data.List?
2021-08-27 15:55:09 <Guest55> ye sure
2021-08-27 15:55:22 <c_wraith> > group [False, False, True, True, False, True, False, False, True, True, True, True, False, False, True, True]
2021-08-27 15:55:23 <lambdabot> [[False,False],[True,True],[False],[True],[False,False],[True,True,True,True...
2021-08-27 15:55:40 <Guest55> well yea lol. but look at what im trying to achive
2021-08-27 15:55:58 <Guest55> i know how to group. just pulling the indexes after that is messy af
2021-08-27 15:56:05 <c_wraith> that's just step one
2021-08-27 15:56:06 <mastarija> Index first
2021-08-27 15:56:18 <mastarija> and then use "groupOn snd"
2021-08-27 15:56:22 <c_wraith> > map (head &&& length) $ group [False, False, True, True, False, True, False, False, True, True, True, True, False, False, True, True]
2021-08-27 15:56:23 <mastarija> or something like that
2021-08-27 15:56:24 <lambdabot> [(False,2),(True,2),(False,1),(True,1),(False,2),(True,4),(False,2),(True,2)]
2021-08-27 15:56:24 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:b5b4:3a1f:2123:21ea)
2021-08-27 15:56:26 <Guest55> ok then assume im way past step 1 now
2021-08-27 15:56:38 <Guest55> ive tryied everything you're saying
2021-08-27 15:56:42 <Guest55> tried*
2021-08-27 15:57:42 <c_wraith> and then at that point, it's probably easiest to go to to explicit recursion
2021-08-27 15:58:01 × raehik quits (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) (Ping timeout: 250 seconds)
2021-08-27 15:58:14 <Guest55> can you show how? that's the exact place im stuck at
2021-08-27 15:58:32 aegon joins (~mike@174.127.249.180)
2021-08-27 15:59:24 cheater joins (~Username@user/cheater)
2021-08-27 16:02:43 <hololeap> is there another way to accomplish this using premade monoids/semigroups/alternatives ... ? http://sprunge.us/0xuc7T
2021-08-27 16:03:03 <c_wraith> Guest55: what should it do if there is no True?
2021-08-27 16:03:40 <Guest55> umm maybe (0,0) idk
2021-08-27 16:03:49 lbseale joins (~lbseale@user/ep1ctetus)
2021-08-27 16:03:58 × lavaman quits (~lavaman@98.38.249.169) (Ping timeout: 250 seconds)
2021-08-27 16:04:01 <Guest55> less of an issue. just an exercise ive come up with
2021-08-27 16:07:18 <hololeap> (fixed it so that it behaves how I actually want: http://sprunge.us/W2QrRQ)
2021-08-27 16:09:12 <hololeap> basically, the folding function doesn't care about previous values, but if they are Just, the first one is kept. the whole thing short circuits when all the Maybes are Just
2021-08-27 16:09:25 <c_wraith> Guest55: https://paste.tomsmeding.com/BAq8Rd3s works. Maybe not ideal (it should probably return a Maybe (Int, Int)), but solid
2021-08-27 16:10:15 pgib joins (~textual@173.38.117.82)
2021-08-27 16:12:30 <hololeap> the overall idea is that it tries to gather all the pieces for building a product type from a list, and once all those pieces have been collected, it stops reading from the list
2021-08-27 16:13:33 <hololeap> I feel like this would be common enough that I wouldn't have to roll my own function for this

All times are in UTC.