Logs: freenode/#haskell
| 2020-11-09 15:31:06 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 256 seconds) |
| 2020-11-09 15:33:05 | <bqv> | man lenses make my head hurt |
| 2020-11-09 15:33:41 | <bqv> | why are people so twisted on monads when lenses are a thing |
| 2020-11-09 15:34:52 | <int-e> | Because you can use Haskell without touching lenses, but you're kind of forced to use at least one monad on occasion? |
| 2020-11-09 15:35:13 | <bqv> | yeah |
| 2020-11-09 15:35:21 | <int-e> | Monads also have a longer history of being scary. |
| 2020-11-09 15:35:22 | <dminuoso> | bqv: Also, if you find lenses a bit too hard to use, you can also try optics |
| 2020-11-09 15:35:30 | <dminuoso> | It offers better readable types and much improved diagnostics |
| 2020-11-09 15:35:49 | <maerwald> | and good documentation |
| 2020-11-09 15:35:54 | <bqv> | any functional difference? |
| 2020-11-09 15:35:56 | <dminuoso> | Part of what makes lens so harsh is that it leaks implementation details in types |
| 2020-11-09 15:36:01 | <maerwald> | bqv: yes, some |
| 2020-11-09 15:36:13 | <bqv> | hm |
| 2020-11-09 15:36:13 | <dminuoso> | bqv: It's a bit safer and doesn't allow some things, also it's missing a few parts left and right |
| 2020-11-09 15:36:15 | → | adm_ joins (~adm@43.229.88.236) |
| 2020-11-09 15:36:18 | <dminuoso> | Overall it's mostly a drop in replacement |
| 2020-11-09 15:36:25 | × | toorevitimirp quits (~tooreviti@117.182.180.38) (Remote host closed the connection) |
| 2020-11-09 15:36:27 | <dminuoso> | (modulo replacing . with %, and unsafe combinators) |
| 2020-11-09 15:36:48 | <bqv> | fair enough |
| 2020-11-09 15:36:48 | <dminuoso> | for example, optics doesnt allow you to `view` through a fold |
| 2020-11-09 15:37:06 | <int-e> | . o O ( please describe lens in a sentence ) |
| 2020-11-09 15:37:06 | × | ystael quits (~ystael@209.6.50.55) (Quit: Lost terminal) |
| 2020-11-09 15:37:56 | <bqv> | something something coalgebras costate comonad... |
| 2020-11-09 15:38:00 | <dminuoso> | "First class selectors for dealing with nested data, like css-selector/xpath" |
| 2020-11-09 15:38:56 | <gehmehgeh> | dminuoso: hmm, so how would implement something as simply as an array 10x10 array? That is 100 elemnts, selectable by coordinates (x,y) such that x and y are in {0,9} ? |
| 2020-11-09 15:39:00 | <gehmehgeh> | *simple |
| 2020-11-09 15:39:13 | × | samlamamma quits (~user@h188-122-129-70.cust.a3fiber.se) (Ping timeout: 264 seconds) |
| 2020-11-09 15:39:15 | <dminuoso> | gehmehgeh: By writing your own index functions |
| 2020-11-09 15:39:17 | <gehmehgeh> | still Vector of VEctor? |
| 2020-11-09 15:39:20 | <dminuoso> | Yes. |
| 2020-11-09 15:39:20 | <gehmehgeh> | hm |
| 2020-11-09 15:39:23 | <gehmehgeh> | ok |
| 2020-11-09 15:39:25 | <gehmehgeh> | will do. Thanks |
| 2020-11-09 15:39:27 | → | ystael joins (~ystael@209.6.50.55) |
| 2020-11-09 15:39:30 | <dminuoso> | For just a matrix, you could use any of the matrix libraires instead too |
| 2020-11-09 15:39:50 | <dminuoso> | like hmatrix if you want a BLAS/LAPACK backed matrix |
| 2020-11-09 15:40:04 | <gehmehgeh> | hmmm |
| 2020-11-09 15:40:19 | × | pjb quits (~t@2a01cb04063ec50070ecdd787f2214a5.ipv6.abo.wanadoo.fr) (Ping timeout: 272 seconds) |
| 2020-11-09 15:40:25 | <dminuoso> | For higher dimensional tensors, it depends. Do you need this with dynamic/arbitrary dimensions? |
| 2020-11-09 15:40:28 | <dminuoso> | Or just fixed 3d? |
| 2020-11-09 15:41:29 | <gehmehgeh> | At the moment, I'm just experimenting |
| 2020-11-09 15:42:06 | <gehmehgeh> | I was thinking about a fixed 10x10 matrix for now, though |
| 2020-11-09 15:42:33 | <dminuoso> | bqv: "coalgebras of the costate comonad" is not just a joke, it's also a sad truth of lens. There's of course folks like edwardk who like being directly exposed to the internals of optics, others like me are not fond of having to decode failed constraints into "what optic did I build, what optic is expected" left and right. |
| 2020-11-09 15:43:27 | <bqv> | i thought i saw a ghc plugin somewhere that improved the errors a bit |
| 2020-11-09 15:43:42 | <bqv> | maybe i just saw the optics library you mentioned |
| 2020-11-09 15:43:42 | <dminuoso> | That's the thing, you can do this in all (ghc-extended) haskell without plugins |
| 2020-11-09 15:43:52 | <bqv> | hm |
| 2020-11-09 15:43:53 | <dminuoso> | optics uses just the standard ghc facilities |
| 2020-11-09 15:44:20 | <dminuoso> | • A_Fold cannot be used as A_Getter |
| 2020-11-09 15:44:52 | → | da39a3ee5e6b4b0d joins (~textual@cm-171-98-71-231.revip7.asianet.co.th) |
| 2020-11-09 15:45:03 | <dminuoso> | * No instance for (Monoid Int) arising from a use of `folded' |
| 2020-11-09 15:45:20 | × | da39a3ee5e6b4b0d quits (~textual@cm-171-98-71-231.revip7.asianet.co.th) (Client Quit) |
| 2020-11-09 15:45:46 | <dminuoso> | I'll take the former over the latter |
| 2020-11-09 15:46:26 | <dminuoso> | Also, with optics you can just say `f % g :: _` and let GHC infer the type for you. And it wont give you some constraint algebra you have to do in your head, but straight up tell you |
| 2020-11-09 15:46:26 | × | Tario quits (~Tario@198.252.153.28) (Read error: Connection reset by peer) |
| 2020-11-09 15:46:31 | <dminuoso> | "This is an AffineTraversal" |
| 2020-11-09 15:46:46 | <dminuoso> | (Okay bad example, since lens cant represent affine traversals) |
| 2020-11-09 15:47:01 | <bqv> | to be honest, i am rather interested in the implementation details anyway, so i'm not against the arcane type signatures |
| 2020-11-09 15:47:15 | <bqv> | but it does obviously make debugging basically black magic until i'm a master of profunctors |
| 2020-11-09 15:48:06 | <dminuoso> | btw, lens already does a mixed van laarhoven/profunctor implementation |
| 2020-11-09 15:48:25 | <dminuoso> | the implementation of optics is not more complicated than that of lens, really |
| 2020-11-09 15:48:48 | <dminuoso> | (I guess much of the weirdnesses of lens are about generalization and performance) |
| 2020-11-09 15:48:55 | → | ddellacosta joins (dd@gateway/vpn/mullvad/ddellacosta) |
| 2020-11-09 15:49:02 | <dminuoso> | and very opaque naming |
| 2020-11-09 15:49:48 | <dminuoso> | Dont get me wrong, I dont have any fundamental problems with lens, but I like not having to decipher type errors. :) |
| 2020-11-09 15:49:53 | <dminuoso> | And I like type inference being on my side |
| 2020-11-09 15:49:57 | × | bliminse quits (~bliminse@host109-156-197-211.range109-156.btcentralplus.com) (Ping timeout: 256 seconds) |
| 2020-11-09 15:50:41 | × | cosimone quits (~cosimone@2001:b07:ae5:db26:d849:743b:370b:b3cd) (Remote host closed the connection) |
| 2020-11-09 15:50:43 | <bqv> | isn't there a lot of stuff that's targeted at compatibility with lens specifically - would those translate? |
| 2020-11-09 15:50:46 | → | bliminse joins (~bliminse@host109-156-197-211.range109-156.btcentralplus.com) |
| 2020-11-09 15:51:05 | → | cosimone joins (~cosimone@2001:b07:ae5:db26:d849:743b:370b:b3cd) |
| 2020-11-09 15:51:25 | <dminuoso> | Well you can translate lenses from VL to optics forth and back |
| 2020-11-09 15:51:45 | <dminuoso> | at least some |
| 2020-11-09 15:51:59 | bqv | . o O ( lens isos? ) |
| 2020-11-09 15:52:11 | <dminuoso> | Or.. well one direction anyway |
| 2020-11-09 15:52:13 | <dminuoso> | foldVL :: (forall f. Applicative f => (a -> f u) -> s -> f v) -> Fold s a |
| 2020-11-09 15:52:15 | <dminuoso> | e.g. |
| 2020-11-09 15:52:17 | ← | iqubic` parts (~user@2601:602:9500:4870:f97f:76da:55:8502) ("ERC (IRC client for Emacs 28.0.50)") |
| 2020-11-09 15:52:30 | <dminuoso> | traversalVL :: TraversalVL s t a b -> Traversal s t a b |
| 2020-11-09 15:53:07 | → | alp joins (~alp@88.126.45.36) |
| 2020-11-09 15:53:18 | <dminuoso> | It would be kind of nice if such packages were written with backpack to have switchable optics implementation |
| 2020-11-09 15:53:38 | <bqv> | yeah.. |
| 2020-11-09 15:53:49 | <gtk> | what is the file extension for Happy grammer file? |
| 2020-11-09 15:54:49 | <dminuoso> | bqv: But honestly, if you write a library, I'd be careful not to expose lenses as part of the main package |
| 2020-11-09 15:55:09 | <dminuoso> | If you wanted to do this at all, try and make a `lib-lenses` package instead, that way someone else can make `lib-optics` too if they desired |
| 2020-11-09 15:55:24 | <dminuoso> | And users who dont want to drag in the transitive dependencies can use it without lens/optics |
| 2020-11-09 15:55:31 | <bqv> | oh, huh. ok |
| 2020-11-09 15:56:40 | → | petersen joins (~petersen@redhat/juhp) |
| 2020-11-09 15:57:19 | <idnar> | dminuoso: one nice thing about `lens` is that you don't need to depend on it to export lenses |
| 2020-11-09 15:57:56 | <dminuoso> | idnar: otoh optics-core is very light on dependencies |
| 2020-11-09 15:57:57 | × | mputz quits (~Thunderbi@dslb-084-058-211-084.084.058.pools.vodafone-ip.de) (Ping timeout: 260 seconds) |
| 2020-11-09 15:58:16 | <dminuoso> | (microlens otoh can be too small) |
| 2020-11-09 16:01:00 | → | Tario joins (~Tario@198.252.153.28) |
| 2020-11-09 16:02:44 | → | pjb joins (~t@2a01cb04063ec50054866239aff0100c.ipv6.abo.wanadoo.fr) |
| 2020-11-09 16:02:48 | × | Tario quits (~Tario@198.252.153.28) (Read error: Connection reset by peer) |
| 2020-11-09 16:04:13 | → | tsaka__ joins (~torstein@ppp-2-84-29-23.home.otenet.gr) |
| 2020-11-09 16:04:15 | × | cosimone quits (~cosimone@2001:b07:ae5:db26:d849:743b:370b:b3cd) (Quit: cosimone) |
| 2020-11-09 16:04:44 | × | acidjnk_new2 quits (~acidjnk@p200300d0c718f646f97e112dfc4bc61a.dip0.t-ipconnect.de) (Ping timeout: 240 seconds) |
| 2020-11-09 16:05:24 | × | thir quits (~thir@p200300f27f0b7e00f4e9381c2bf90854.dip0.t-ipconnect.de) (Ping timeout: 240 seconds) |
| 2020-11-09 16:06:51 | × | adm_ quits (~adm@43.229.88.236) (Remote host closed the connection) |
All times are in UTC.