Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,533 events total
2021-08-27 16:14:24 × phma quits (~phma@host-67-44-208-131.hnremote.net) (Read error: Connection reset by peer)
2021-08-27 16:15:51 phma joins (~phma@host-67-44-208-218.hnremote.net)
2021-08-27 16:16:36 <sclv> hololeap: i'd just say `find (\(x,y) -> isJust x && isJust y)` or something for that?
2021-08-27 16:18:41 <sclv> but what you may want is something like `concatMap (\(x,y) -> liftM2 (,) x y)` and then pattern match out the head
2021-08-27 16:18:53 <sclv> or er not concatMap, but mapMaybe
2021-08-27 16:19:36 _ht joins (~quassel@82-169-194-8.biz.kpn.net)
2021-08-27 16:21:21 × azeem quits (~azeem@176.201.15.153) (Ping timeout: 248 seconds)
2021-08-27 16:22:33 <c_wraith> there are so many silly ways to do this:
2021-08-27 16:22:34 <c_wraith> :t \f -> getFirst . foldMap (First . uncurry (liftA2 (,)) . f)
2021-08-27 16:22:35 <lambdabot> Foldable t => (a1 -> (Maybe a2, Maybe b)) -> t a1 -> Maybe (a2, b)
2021-08-27 16:23:28 <Guest55> c_wraith thanks. ill try to understand what you wrote
2021-08-27 16:23:49 <c_wraith> Ah, that version isn't quite right. To really be right you'd want to bimap over the pair, which gets uglier
2021-08-27 16:24:18 <byorgey> what's an easy way to get a function Map k (Maybe a) -> Map k a which deletes the Nothing values from the map?
2021-08-27 16:24:36 <c_wraith> :t \f -> bimap getFirst getFirst . foldMap (bimap First First . f)
2021-08-27 16:24:37 <lambdabot> (Bifunctor p, Foldable t, Monoid (p (First a1) (First a2))) => (a3 -> p (Maybe a1) (Maybe a2)) -> t a3 -> p (Maybe a1) (Maybe a2)
2021-08-27 16:24:40 <hololeap> c_wraith: that would discard an intermediate value like (Just x, Nothing) ... the `uncurry (liftA2 (,))` would transform that into Nothing and you would lose `Just x`
2021-08-27 16:24:42 <c_wraith> enjoy that type signature
2021-08-27 16:24:48 <c_wraith> hololeap: yes, I just fixed that
2021-08-27 16:25:05 <Guest55> the problem btw was to find longest increasing&following number subsequence
2021-08-27 16:25:11 <sclv> byorgey: the easiest way is to use witherable :-)
2021-08-27 16:25:44 <Guest55> i just converted it to a lists of booleans indicating if one is a successor of the previous
2021-08-27 16:26:06 <byorgey> sclv: ah, perfect!
2021-08-27 16:26:57 <byorgey> Yes, exactly. I used to have a list and used catMaybes. But now the list is changing to a map, and... I can still use catMaybes! \o/
2021-08-27 16:29:29 azeem joins (~azeem@176.200.202.67)
2021-08-27 16:29:35 <dminuoso> byorgey: traverseMaybeWithKey is a thing in new versions of container
2021-08-27 16:29:43 <dminuoso> Avoids the dependency on witherable
2021-08-27 16:29:47 <c_wraith> hololeap: though.. I'm not sure that's appropriately lazy anymore, since the Firsts are inside the tuple. Better off going with one of sclv's suggestsions
2021-08-27 16:30:24 × Morrow_ quits (~Morrow@bzq-110-168-31-106.red.bezeqint.net) (Ping timeout: 250 seconds)
2021-08-27 16:31:29 <dminuoso> Though catMaybes from witherable might be a better exact fit. But traverseMaybeWithKey is still useful in case this is the output of a traverse already.
2021-08-27 16:33:59 <byorgey> dminuoso: oh, good to know, thanks, that's actually an even better fit, because I do a traverse right before the catMaybes
2021-08-27 16:35:54 markpythonicbtc joins (~textual@2601:647:5a00:35:f814:103:43a8:3466)
2021-08-27 16:39:24 × dschrempf quits (~dominik@070-207.dynamic.dsl.fonira.net) (Quit: WeeChat 3.2)
2021-08-27 16:41:25 arjun joins (~Srain@user/arjun)
2021-08-27 16:47:40 × azeem quits (~azeem@176.200.202.67) (Ping timeout: 252 seconds)
2021-08-27 16:48:25 × Guest55 quits (~Guest55@188.64.207.213) (Ping timeout: 246 seconds)
2021-08-27 16:50:01 × Boomerang quits (~Boomerang@xd520f68c.cust.hiper.dk) (Ping timeout: 250 seconds)
2021-08-27 16:51:59 martin02 joins (~silas@141.84.69.76)
2021-08-27 16:52:15 azeem joins (~azeem@176.200.202.67)
2021-08-27 16:53:03 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:b5b4:3a1f:2123:21ea) (Remote host closed the connection)
2021-08-27 16:55:02 × arjun quits (~Srain@user/arjun) (Remote host closed the connection)
2021-08-27 16:59:51 <maerwald> is there an easy way to make the Map fromJSON instance of aeson more permissive without redefining it? As in: if it can't parse a key, I want it to just skip that element
2021-08-27 17:00:47 <sclv> https://hackage.haskell.org/package/aeson-1.5.6.0/docs/Data-Aeson.html#v:defaultOptions is all i know of?
2021-08-27 17:01:03 <maerwald> the instance is here https://hackage.haskell.org/package/aeson-1.5.6.0/docs/src/Data.Aeson.Types.FromJSON.html#line-1896
2021-08-27 17:01:09 <maerwald> I'm sure I could just overwrite it, but
2021-08-27 17:01:45 <maerwald> it seems like a common use case, isn't it?
2021-08-27 17:02:07 <sclv> i'm not sure i see where that errors -- as in the key can't be parsed because its malformed as json?
2021-08-27 17:02:11 mc47 joins (~mc47@xmonad/TheMC47)
2021-08-27 17:02:15 <dminuoso> Dunno, the the protocol interactions we have are very strict.
2021-08-27 17:02:18 × mastarija quits (~mastarija@78-3-210-70.adsl.net.t-com.hr) (Read error: Connection reset by peer)
2021-08-27 17:02:26 <dminuoso> Simply dropping keys could induce a lot of bizarre failure
2021-08-27 17:02:29 <maerwald> well, `FromJSONKey k` will fail
2021-08-27 17:02:36 <maerwald> it would have to catch it
2021-08-27 17:02:54 Morrow_ joins (~Morrow@bzq-110-168-31-106.red.bezeqint.net)
2021-08-27 17:03:35 <sclv> oh uh i'd just parse into a map from string keys in that case
2021-08-27 17:05:43 elf_fortrez joins (~elf_fortr@adsl-72-50-7-8.prtc.net)
2021-08-27 17:05:43 <maerwald> that's gonna be a little annoyong, because those are several nested maps, which then have to be translated to something not-stringy :p
2021-08-27 17:06:13 <maerwald> I guess I'll just make an overlapping instance
2021-08-27 17:06:15 <sclv> ok then newtype wrap the maps and write your own instance?
2021-08-27 17:07:07 × vpan quits (~vilius@212.117.1.172) (Quit: Leaving.)
2021-08-27 17:08:01 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Ping timeout: 252 seconds)
2021-08-27 17:08:04 × smitop quits (~smitop@user/smitop) (Remote host closed the connection)
2021-08-27 17:10:14 <aegon> i'm trying to grok arrow syntax better / when its good to use anyone got a favorite tutorial / overview? I've got 6 open
2021-08-27 17:10:25 × nilof quits (~olofs@90-227-86-119-no542.tbcn.telia.com) (Ping timeout: 248 seconds)
2021-08-27 17:12:06 fef joins (~thedawn@user/thedawn)
2021-08-27 17:12:24 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:b5b4:3a1f:2123:21ea)
2021-08-27 17:13:37 <maerwald> in 8 years of haskell or so I've never used arrows
2021-08-27 17:13:51 <maerwald> although I've read several papers that make use of them
2021-08-27 17:14:18 <maerwald> then they usually end up doing something similar with monads
2021-08-27 17:15:57 <aegon> i did something with wire a while back. It seems like the intent is that arrows can be paralellized but I don't see any parallelization happening unless ghc is doing that when it sees they aren't dependent on eachother
2021-08-27 17:16:07 <maerwald> whenever I try to build an intuition about them, I simply can't find enough use cases
2021-08-27 17:16:30 MQ-17J joins (~MQ-17J@d14-69-206-129.try.wideopenwest.com)
2021-08-27 17:17:12 tzh joins (~tzh@c-24-21-73-154.hsd1.or.comcast.net)
2021-08-27 17:17:12 × tput quits (~tim@S0106a84e3fe54613.ed.shawcable.net) (Ping timeout: 250 seconds)
2021-08-27 17:17:33 <maerwald> and then I wonder why I spent 2 hours reading about something I don't need :p
2021-08-27 17:18:33 <aegon> lol
2021-08-27 17:18:50 <hololeap> sclv, c_wraith: the best solution I've come up with so far is to roll a First2 monoid: http://sprunge.us/9RSGe0
2021-08-27 17:18:53 <aegon> i want all that sugar at my disposal when planning
2021-08-27 17:19:23 <maerwald> except for making an impression at the next haskell meetup
2021-08-27 17:19:30 <maerwald> where ppl will go "omg, that arrow dude"
2021-08-27 17:20:09 smitop joins (~smitop@user/smitop)
2021-08-27 17:20:35 nilof joins (~olofs@90-227-86-119-no542.tbcn.telia.com)
2021-08-27 17:20:48 <hololeap> but it would be cool to find a solution that could do this with any number of arguments
2021-08-27 17:21:36 <maerwald> also, 'arrow' is a hell of a nickname
2021-08-27 17:24:56 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-08-27 17:26:33 <[exa]> hololeap: take `both First` (with `both` from tuple extras) and generalize over `both` ?
2021-08-27 17:28:22 × wroathe quits (~wroathe@user/wroathe) (Ping timeout: 252 seconds)
2021-08-27 17:29:38 <[exa]> (and well, unzip)
2021-08-27 17:29:47 × nilof quits (~olofs@90-227-86-119-no542.tbcn.telia.com) (Quit: Leaving)
2021-08-27 17:29:55 × dyeplexer quits (~dyeplexer@user/dyeplexer) (Quit: Leaving)
2021-08-27 17:30:49 <hololeap> hm, no both needs the tuple to look like (a,a), which isn't the case here... the tuple here is (Maybe a, Maybe b)
2021-08-27 17:31:38 <[exa]> ah so that would make a higher-order-polymorphic `both`
2021-08-27 17:33:04 dsrt^ joins (~dsrt@12.16.129.111)
2021-08-27 17:33:48 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:b5b4:3a1f:2123:21ea) (Remote host closed the connection)
2021-08-27 17:34:13 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Ping timeout: 250 seconds)
2021-08-27 17:36:07 MQ-17J joins (~MQ-17J@d14-69-206-129.try.wideopenwest.com)
2021-08-27 17:39:57 chris joins (~chris@81.96.113.213)
2021-08-27 17:40:00 chris is now known as Guest1015
2021-08-27 17:40:10 × notzmv quits (~zmv@user/notzmv) (Ping timeout: 240 seconds)
2021-08-27 17:41:31 Skyfire joins (~pyon@user/pyon)
2021-08-27 17:43:27 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Ping timeout: 240 seconds)

All times are in UTC.