Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,375 events total
2021-08-23 11:27:16 <timCF> it's not working as expected without `_Just` prism. For example `x ^? Msg.maybe'ok` will produce `Just Nothing` which will always return True with isJust (case where we just checking that response is ok or not). To make it work as expected, we should use `x ^? Msg.maybe'ok . _Just` or `x ^. Msg.maybe'ok`. And type system is not helping that much in case of this kind of errors. I thought maybe I can solve
2021-08-23 11:27:22 <timCF> the issue if `^?` is not imported, then developers are forced to use `^.` but seems like it's not working with nested fields, for example `x ^. Msg.maybe'ok . _Just . Msg.maybe'user` will fail to compile with some strange error about Monoid instances. I don'
2021-08-23 11:27:36 <timCF> I don't like solution like "triple check what you are actually writing" and prefer type system to help
2021-08-23 11:27:54 <dminuoso> timCF: Switch to `optics` then.
2021-08-23 11:27:58 × azeem quits (~azeem@176.201.15.223) (Ping timeout: 252 seconds)
2021-08-23 11:27:58 <timCF> Are there any suggestions how to fix this kind of issue?
2021-08-23 11:28:04 <dminuoso> The underlying problem is roughly this:
2021-08-23 11:28:58 <dminuoso> % :t view
2021-08-23 11:28:59 <yahb> dminuoso: MonadReader s m => Getting a s a -> m a
2021-08-23 11:29:01 <dminuoso> % :i Getting
2021-08-23 11:29:02 <yahb> dminuoso: type Getting :: * -> * -> * -> *; type Getting r s a = (a -> Const r a) -> s -> Const r s; -- Defined in `Control.Lens.Getter'
2021-08-23 11:29:09 azeem joins (~azeem@176.201.15.223)
2021-08-23 11:29:34 <dminuoso> % :t _Just . _1
2021-08-23 11:29:34 <yahb> dminuoso: (Applicative f, Field1 a1 b1 a2 b2) => (a2 -> f b2) -> Maybe a1 -> f (Maybe b1)
2021-08-23 11:30:14 <dminuoso> timCF: Notice how we have this `Applicative` constraint?
2021-08-23 11:30:30 <dminuoso> Essentially what this all ends up doing is:
2021-08-23 11:30:47 <dminuoso> In `lens` we can `view` through a Fold, and it will just `mappend` all targets together
2021-08-23 11:30:52 <dminuoso> If no target exist, you get `mempty` back
2021-08-23 11:30:57 <dminuoso> e.g.:
2021-08-23 11:31:12 <dminuoso> % view folded [Product 1, Product 2, Product 3, Product 4]
2021-08-23 11:31:13 <yahb> dminuoso: Product {getProduct = 24}
2021-08-23 11:31:34 <dminuoso> This may not be what you intended, and its one of those things why I dont like `lens` either.
2021-08-23 11:31:47 × drd quits (~drd@2001:b07:a70:9f1f:1562:34de:f50f:77d4) (Ping timeout: 240 seconds)
2021-08-23 11:32:23 <dibblego> timCF: a lens composed with a prism gives you a traversal
2021-08-23 11:33:08 <timCF> dminuoso: I see. Does `optics` "solves" it somehow? Not sure is it bug or feature)
2021-08-23 11:33:14 <dminuoso> Yes.
2021-08-23 11:33:29 <dminuoso> Let me quickly give you the output
2021-08-23 11:34:18 × vysn quits (~vysn@user/vysn) (Remote host closed the connection)
2021-08-23 11:34:25 <dminuoso> timCF: https://gist.github.com/dminuoso/58f816500a5cd9fa4affff440e301af6
2021-08-23 11:34:49 <dminuoso> So if you wanted the behavior of `lens`, you'd have to explicitly use `foldOf`
2021-08-23 11:35:03 <dminuoso> Otherwise you get very well written customed type errors
2021-08-23 11:36:08 <dminuoso> Or perhaps, as a comparable example:
2021-08-23 11:36:23 <dminuoso> % view (_Just . _1) (Just ("foo", bar))
2021-08-23 11:36:25 <yahb> dminuoso: ; <interactive>:13:33: error:; * Variable not in scope: bar; * Perhaps you meant `Sym.var' (imported from Data.Number.Symbolic)
2021-08-23 11:36:28 <dminuoso> % view (_Just . _1) (Just ("foo", 1))
2021-08-23 11:36:29 <yahb> dminuoso: "foo"
2021-08-23 11:37:00 <dminuoso> https://gist.github.com/dminuoso/4195934615b775b3ef7514f97b63dcc7
2021-08-23 11:37:07 <dminuoso> The output you'd get in optics
2021-08-23 11:37:40 <dminuoso> (The output here means, that the composition of `_Just % _1` is an AffineTraversal, but `view` demands a Getter
2021-08-23 11:37:40 × dschrempf quits (~dominik@92-249-199-97.pool.digikabel.hu) (Ping timeout: 240 seconds)
2021-08-23 11:37:50 lavaman joins (~lavaman@98.38.249.169)
2021-08-23 11:38:57 <timCF> dminuoso: Thanks! I'll try this! I hope `optics` will be compatible with `proto-lens`
2021-08-23 11:39:25 <dminuoso> timCF: Mmm not directly.
2021-08-23 11:40:02 <dminuoso> I mean you can trivially convert between lens-style and optics-style optics, but its additional work
2021-08-23 11:40:18 <Jack> Anyone ever taken a look at C++'s "functional" library?
2021-08-23 11:42:22 × lavaman quits (~lavaman@98.38.249.169) (Ping timeout: 250 seconds)
2021-08-23 11:44:17 <[exa]> Jack: yes
2021-08-23 11:46:37 jakalx parts (~jakalx@base.jakalx.net) (Error from remote client)
2021-08-23 11:47:23 cheater1__ joins (~Username@user/cheater)
2021-08-23 11:47:36 × cheater quits (~Username@user/cheater) (Ping timeout: 268 seconds)
2021-08-23 11:47:37 cheater1__ is now known as cheater
2021-08-23 11:49:55 <Jack> It's kind of adorable, isn't it
2021-08-23 11:51:49 doyougnu joins (~user@c-73-25-202-122.hsd1.or.comcast.net)
2021-08-23 11:51:57 <[exa]> depends on the kind of adorable you're after
2021-08-23 11:52:07 <[exa]> std::bind is often a lifesaver
2021-08-23 11:52:47 <Rembane_> [exa]: Is std::bind like $ in Haskell?
2021-08-23 11:53:09 <[exa]> literally like ' ', yea
2021-08-23 11:53:18 favonia joins (~favonia@user/favonia)
2021-08-23 11:53:52 <[exa]> afaik it implements a pretty good static representation of the closure
2021-08-23 11:54:32 <Rembane_> Do you get that sweet lisp scoping when you use std::bind?
2021-08-23 11:54:58 <[exa]> lisp scope is structural or lexical?
2021-08-23 11:55:03 <[exa]> (I can never remember)
2021-08-23 11:55:14 <Rembane_> Me neither, so I guess we're stuck now. :)
2021-08-23 11:55:25 <[exa]> anyway the scope is perfectly c++ish
2021-08-23 11:55:41 <Rembane_> If everything works as expected it's fine imo
2021-08-23 11:56:08 <[exa]> yeah it really works, if you want to do a partial application std::bind is the way
2021-08-23 11:57:03 <[exa]> or a std::thunk <-- fiction
2021-08-23 11:57:06 × haskl quits (~haskl@user/haskl) (Remote host closed the connection)
2021-08-23 11:59:05 haskl joins (~haskl@98.37.78.63)
2021-08-23 11:59:09 <Rembane_> It's a good thunk.
2021-08-23 12:00:35 × azeem quits (~azeem@176.201.15.223) (Read error: Connection reset by peer)
2021-08-23 12:00:54 × haskl quits (~haskl@98.37.78.63) (Changing host)
2021-08-23 12:00:54 haskl joins (~haskl@user/haskl)
2021-08-23 12:01:12 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:71e9:72b:1860:cb0f)
2021-08-23 12:01:54 azeem joins (~azeem@dynamic-adsl-94-34-33-6.clienti.tiscali.it)
2021-08-23 12:03:51 <timCF> dminuoso: I also thought maybe I can avoid `^?` using monadic nature of maybe, so `x ^? maybe'foo . _Just . maybe'bar . _Just` can be rewritten as `x ^. maybe'foo >>= (^. maybe'bar)` but I'm afraid it's even more confusing. But maybe not :)
2021-08-23 12:04:29 Ariakenom joins (~patrik@c83-255-154-140.bredband.tele2.se)
2021-08-23 12:05:46 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:71e9:72b:1860:cb0f) (Ping timeout: 250 seconds)
2021-08-23 12:07:27 [itchyjunk] joins (~itchyjunk@user/itchyjunk/x-7353470)
2021-08-23 12:11:49 pbrisbin joins (~patrick@174-081-116-011.res.spectrum.com)
2021-08-23 12:13:54 × Ariakenom quits (~patrik@c83-255-154-140.bredband.tele2.se) (Quit: WeeChat 3.1)
2021-08-23 12:14:08 Ariakenom joins (~patrik@c83-255-154-140.bredband.tele2.se)
2021-08-23 12:20:32 dschrempf joins (~dominik@92-249-199-97.pool.digikabel.hu)
2021-08-23 12:31:24 × bitdex quits (~bitdex@gateway/tor-sasl/bitdex) (Ping timeout: 244 seconds)
2021-08-23 12:35:43 jakalx joins (~jakalx@base.jakalx.net)
2021-08-23 12:36:04 × urdh quits (~urdh@user/urdh) (Quit: Boom!)
2021-08-23 12:36:50 × [itchyjunk] quits (~itchyjunk@user/itchyjunk/x-7353470) (Remote host closed the connection)
2021-08-23 12:37:04 burnsidesLlama joins (~burnsides@dhcp168-023.wadham.ox.ac.uk)
2021-08-23 12:38:16 jacks2 joins (~bc8167eb@217.29.117.252)
2021-08-23 12:38:49 <jacks2> hi. given parsec's someParser :: Parser a, is it possible to get current line number in someParser?
2021-08-23 12:42:07 pretty_dumm_guy joins (trottel@gateway/vpn/protonvpn/prettydummguy/x-88029655)
2021-08-23 12:42:11 × pretty_dumm_guy quits (trottel@gateway/vpn/protonvpn/prettydummguy/x-88029655) (Client Quit)
2021-08-23 12:42:27 pretty_dumm_guy joins (trottel@gateway/vpn/protonvpn/prettydummguy/x-88029655)
2021-08-23 12:42:51 × pretty_dumm_guy quits (trottel@gateway/vpn/protonvpn/prettydummguy/x-88029655) (Client Quit)
2021-08-23 12:44:17 × keutoi quits (~keutoi@106.208.52.176) (Ping timeout: 248 seconds)
2021-08-23 12:44:57 × markpythonicbtc quits (~textual@2601:647:5a00:35:d936:f2de:ef6:f0f4) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-08-23 12:45:13 urdh joins (~urdh@user/urdh)
2021-08-23 12:47:29 pretty_dumm_guy joins (trottel@gateway/vpn/protonvpn/prettydummguy/x-88029655)
2021-08-23 12:49:40 × hendursa1 quits (~weechat@user/hendursaga) (Quit: hendursa1)
2021-08-23 12:50:18 hendursaga joins (~weechat@user/hendursaga)

All times are in UTC.