Logs: freenode/#haskell
| 2020-10-06 04:36:31 | <hololeap> | :t \x y -> _ (x + y) |
| 2020-10-06 04:36:36 | <lambdabot> | error: |
| 2020-10-06 04:36:36 | <lambdabot> | • Found hole: _ :: t -> t1 |
| 2020-10-06 04:36:36 | <lambdabot> | Where: ‘t’, ‘t1’ are rigid type variables bound by |
| 2020-10-06 04:37:13 | → | haritz joins (~hrtz@62.3.70.206) |
| 2020-10-06 04:37:14 | × | haritz quits (~hrtz@62.3.70.206) (Changing host) |
| 2020-10-06 04:37:14 | → | haritz joins (~hrtz@unaffiliated/haritz) |
| 2020-10-06 04:38:39 | → | day_ joins (~Unknown@unaffiliated/day) |
| 2020-10-06 04:39:29 | <gnumonik> | I'm not even sure how to break this down. I've been at this for more than a week... This seems like it should work: myFunc adt val adtLens fieldPrism i = set' (adtLens . ix i . fieldPrism) val adt. But it doesn't for the list-of-sums-inside-a-product. The sketchy part, as far as I can tell, is that the product type doesn't have an instance of a class that it can't possibly have. Oh well. |
| 2020-10-06 04:39:53 | → | takuan joins (~takuan@178-116-218-225.access.telenet.be) |
| 2020-10-06 04:40:29 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2020-10-06 04:41:02 | × | zoom84 quits (~zoom55aa@068-190-177-201.res.spectrum.com) (Quit: WeeChat 2.9) |
| 2020-10-06 04:41:18 | → | zoom84 joins (~user@068-190-177-201.res.spectrum.com) |
| 2020-10-06 04:41:56 | × | day quits (~Unknown@unaffiliated/day) (Ping timeout: 272 seconds) |
| 2020-10-06 04:41:56 | day_ | is now known as day |
| 2020-10-06 04:42:21 | <Axman6> | gnumonik: can you share a more concrete example? |
| 2020-10-06 04:44:39 | <Axman6> | gnumonik: given that code it's difficult to tell what the types are, I can sort of infer them, but some type signatures and definitions of the sums and products would be good |
| 2020-10-06 04:45:44 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 272 seconds) |
| 2020-10-06 04:46:09 | <Axman6> | :t set' |
| 2020-10-06 04:46:11 | <lambdabot> | ASetter' s a -> a -> s -> s |
| 2020-10-06 04:46:16 | <Axman6> | :t set |
| 2020-10-06 04:46:18 | <lambdabot> | ASetter s t a b -> b -> s -> t |
| 2020-10-06 04:47:32 | <hololeap> | doesn't lens composition get reversed from the usual order, e.g. (fieldPrism . ix i . adtLens), assuming that the sum type is the "topmost" structure |
| 2020-10-06 04:47:56 | × | solonarv quits (~solonarv@adijon-655-1-70-207.w90-13.abo.wanadoo.fr) (Ping timeout: 256 seconds) |
| 2020-10-06 04:47:58 | × | zacts quits (~zacts@dragora/developer/zacts) (Quit: leaving) |
| 2020-10-06 04:48:11 | × | brandly quits (~brandly@c-73-68-15-46.hsd1.ma.comcast.net) (Ping timeout: 240 seconds) |
| 2020-10-06 04:48:32 | <Axman6> | yeah if it's a product containing a list containing a sum then it would be fieldLens . ix i . sumPrism |
| 2020-10-06 04:48:43 | <hololeap> | "topmost" isn't very descriptive. i mean the first structure you navigate |
| 2020-10-06 04:48:54 | <hololeap> | right |
| 2020-10-06 04:49:07 | <Axman6> | it looks to me like it is doing the right thing, assuming it is what I said it is |
| 2020-10-06 04:50:43 | <hololeap> | oh, so it would be the normal order of composition then (same as functions)? i remembered composing lens' to be the opposite of what you usually do |
| 2020-10-06 04:51:54 | <gnumonik> | It's actually a sum containing a product containing a list of sums. The actual context of this is pretty substantial. I'm writing a protocol analyzer that wraps different message types in one big sum type. The 'adtLens' thing is actually a composition of lenses and prisms but I dunno that that matters |
| 2020-10-06 04:52:28 | <hololeap> | sorry, i misread |
| 2020-10-06 04:52:35 | hololeap | edges away from the conversation |
| 2020-10-06 04:54:08 | <dsal> | > Right (1, [Right 2, Left 3, Right 4]) ^.. _Right . _2 . folded . _Right |
| 2020-10-06 04:54:11 | <lambdabot> | [2,4] |
| 2020-10-06 04:56:23 | <dsal> | > Right (1, [Right 2, Left 3, Right 4]) & _Right . _2 . traversed . _Right %~ (^2) |
| 2020-10-06 04:56:25 | <lambdabot> | Right (1,[Right 4,Left 3,Right 16]) |
| 2020-10-06 04:56:32 | <Axman6> | :t (folded, each) |
| 2020-10-06 04:56:34 | <lambdabot> | (Indexable Int p, Contravariant f1, Each s t a1 b, Foldable f2, Applicative f1, Applicative f3) => (p a2 (f1 a2) -> f2 a2 -> f1 (f2 a2), (a1 -> f3 b) -> s -> f3 t) |
| 2020-10-06 04:56:44 | × | zoom84 quits (~user@068-190-177-201.res.spectrum.com) (Quit: WeeChat 2.9) |
| 2020-10-06 04:57:03 | <dsal> | Oh, I never think of each like that. That's pretty neat. |
| 2020-10-06 04:57:15 | <dsal> | Lens doesn't fit in my tiny headcache |
| 2020-10-06 04:58:55 | × | ixian quits (~mgold@2002:4a74:ba78:1701:0:ff:fe78:6269) (Ping timeout: 240 seconds) |
| 2020-10-06 05:00:37 | → | ixian joins (~mgold@terra.bitplane.org) |
| 2020-10-06 05:01:26 | <gnumonik> | Ugh I can't even make this more concrete. If there's nothing wrong with that function then I think I just can't do what I want with lens. That's literally the function I use. |
| 2020-10-06 05:03:28 | × | dansho quits (~dansho@ip68-108-167-185.lv.lv.cox.net) (Remote host closed the connection) |
| 2020-10-06 05:04:12 | <dsal> | The above examples match your description. It's hard to guess what you're doing differently. |
| 2020-10-06 05:06:28 | hackage | reanimate-svg 0.12.1.0 - SVG file loader and serializer https://hackage.haskell.org/package/reanimate-svg-0.12.1.0 (DavidHimmelstrup) |
| 2020-10-06 05:09:44 | × | mathlover2 quits (~mathlover@2604:6000:1013:129e:755e:eccf:8735:da37) (Quit: Leaving) |
| 2020-10-06 05:09:55 | × | falafel quits (~falafel@2605:e000:1527:d491:99fe:5613:f0a7:56f0) (Ping timeout: 240 seconds) |
| 2020-10-06 05:10:35 | → | xff0x joins (~fox@2001:1a81:5339:8000:bdc7:ef33:4985:5e4f) |
| 2020-10-06 05:10:44 | → | GyroW_ joins (~GyroW@ptr-48ujrfd1ztq5fjywfw3.18120a2.ip6.access.telenet.be) |
| 2020-10-06 05:10:45 | × | GyroW_ quits (~GyroW@ptr-48ujrfd1ztq5fjywfw3.18120a2.ip6.access.telenet.be) (Changing host) |
| 2020-10-06 05:10:45 | → | GyroW_ joins (~GyroW@unaffiliated/gyrow) |
| 2020-10-06 05:11:07 | × | GyroW quits (~GyroW@unaffiliated/gyrow) (Ping timeout: 260 seconds) |
| 2020-10-06 05:11:53 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2020-10-06 05:13:29 | <gnumonik> | Well, if I'm going to start over I have a question: My goal here is to find a way to expose lens functionality to the user without writing a bunch of boilerplate for every record field/constructor. I was trying to use TH to generate parsers for every valid combination of nested records/type constructors (i.e. the string "foo.bar" parses to the composition of lenses foo and bar). Is there an... obvious easier way to do that? |
| 2020-10-06 05:13:54 | → | coot joins (~coot@37.30.49.218.nat.umts.dynamic.t-mobile.pl) |
| 2020-10-06 05:14:42 | <dsal> | the lens library does that for you. |
| 2020-10-06 05:16:42 | <gnumonik> | huh? how? |
| 2020-10-06 05:16:43 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 260 seconds) |
| 2020-10-06 05:18:27 | → | snakemasterflex joins (~snakemast@213.100.206.23) |
| 2020-10-06 05:18:33 | × | Tritlo quits (sid58727@gateway/web/irccloud.com/x-vuffzyrxnybrguux) (Ping timeout: 272 seconds) |
| 2020-10-06 05:18:50 | × | howdoi quits (uid224@gateway/web/irccloud.com/x-bfkecngtkcukjezu) (Quit: Connection closed for inactivity) |
| 2020-10-06 05:19:55 | → | ishutin_ joins (~Ishutin@193-110-63-54.cable-modem.hdsnet.hu) |
| 2020-10-06 05:20:10 | → | Tritlo joins (sid58727@gateway/web/irccloud.com/x-gcmzpwtjgmfrhnky) |
| 2020-10-06 05:20:13 | <gnumonik> | Er maybe that wasn't clear. What I really need is a function :: String -> Lens, since I was hoping to use the functionality in a small DSL. When I say I'm trying to generate parsers, I mean functions that take strings and spit out lenses/prisms/traversals. (I'm sorry if this is stupid, Haskell's my first programming language and I've been teaching myself without much guidance) |
| 2020-10-06 05:22:45 | × | snakemasterflex quits (~snakemast@213.100.206.23) (Ping timeout: 240 seconds) |
| 2020-10-06 05:23:18 | × | ishutin quits (~Ishutin@92-249-150-146.static.digikabel.hu) (Ping timeout: 260 seconds) |
| 2020-10-06 05:24:41 | → | petersen joins (~petersen@redhat/juhp) |
| 2020-10-06 05:26:45 | → | snakemasterflex joins (~snakemast@213.100.206.23) |
| 2020-10-06 05:27:01 | × | kori quits (~kori@arrowheads/kori) (Ping timeout: 244 seconds) |
| 2020-10-06 05:27:27 | × | spew quits (uid195861@gateway/web/irccloud.com/x-zoqmilcrntqznxpj) (Quit: Connection closed for inactivity) |
| 2020-10-06 05:36:10 | → | idhugo joins (~idhugo@563472ae.rev.stofanet.dk) |
| 2020-10-06 05:37:18 | × | snakemasterflex quits (~snakemast@213.100.206.23) (Ping timeout: 260 seconds) |
| 2020-10-06 05:37:43 | → | falafel joins (~falafel@2605:e000:1527:d491:99fe:5613:f0a7:56f0) |
| 2020-10-06 05:37:47 | × | shailangsa quits (~shailangs@host165-120-169-97.range165-120.btcentralplus.com) (Ping timeout: 240 seconds) |
| 2020-10-06 05:37:48 | → | snakemasterflex joins (~snakemast@213.100.206.23) |
| 2020-10-06 05:41:42 | <jackdk> | I think dsal's saying that the point of lens is that lenses themselves compose with `.`, so you shouldn't feel like you have to generate all the compositions yourself |
| 2020-10-06 05:43:50 | → | kori joins (~kori@arrowheads/kori) |
| 2020-10-06 05:45:31 | <dsal> | Well, I mean you don't have to generate the boilerplate for every field. That's what makeLenses does. But doing this at runtime is a bit weird. |
| 2020-10-06 05:46:47 | <[exa]> | kindof guess that gnumonik only wants an autogenerated dictionary that does f "foo" = foo |
| 2020-10-06 05:47:10 | <[exa]> | the rest (like parsing out the dot and joining the results) can be easily done with the parser |
| 2020-10-06 05:47:57 | hackage | hoauth2 1.16.0 - Haskell OAuth2 authentication client https://hackage.haskell.org/package/hoauth2-1.16.0 (HaishengWu) |
| 2020-10-06 05:48:28 | <gnumonik> | yeah, ideally i'd not have to pre-generate the entire string, but that seemed to work (up to a point anyway) whereas storing a variety of differently-typed lenses in any kind of data structure did not |
| 2020-10-06 05:48:58 | × | idhugo quits (~idhugo@563472ae.rev.stofanet.dk) (Ping timeout: 260 seconds) |
| 2020-10-06 05:49:06 | <dsal> | How would a user use this mechanism? |
| 2020-10-06 05:49:43 | <dsal> | Is it just about making runtime errors out of lens expressions? |
| 2020-10-06 05:51:09 | → | albert_91 joins (~Albert@p200300e5ff0b5b4248a33bded2872db1.dip0.t-ipconnect.de) |
| 2020-10-06 05:52:51 | <gnumonik> | Not really. I wanted to somehow leverage lens to allow a user to select fields in data types that represent network packets and filter or replace those fields. But given that there are... i dunno, a few thousand network protocols out there, I wanted some way of automating the construction of functions for doing those things. |
| 2020-10-06 05:53:01 | → | bahamas joins (~lucian@unaffiliated/bahamas) |
| 2020-10-06 05:54:26 | <dsal> | I think that makes sense. The string is throwing me off, though. I think it's a confusing detail. If you didn't have the string, and someone were using your library, what would they have to do now in one example? |
| 2020-10-06 05:55:25 | × | albert_91 quits (~Albert@p200300e5ff0b5b4248a33bded2872db1.dip0.t-ipconnect.de) (Ping timeout: 240 seconds) |
| 2020-10-06 05:55:47 | → | shatriff joins (~vitaliish@217.27.153.240) |
| 2020-10-06 05:56:55 | → | thir joins (~thir@p200300f27f0fc60038c1b16891cbfa03.dip0.t-ipconnect.de) |
| 2020-10-06 05:57:23 | <dsal> | because, as jackdk says, you don't need to generate all the combinations, but you might be able to write some useful helpers that skip a few common steps. |
| 2020-10-06 06:00:01 | × | MasterGruntR75 quits (~MasterGru@185.244.214.216) () |
| 2020-10-06 06:03:07 | → | aplainze1akind joins (~johndoe@captainludd.powered.by.lunarbnc.net) |
| 2020-10-06 06:03:15 | → | jcarpenter2 joins (~rofl@96.78.87.197) |
All times are in UTC.