Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→
Page 1 .. 88 89 90 91 92 93 94 95 96 97 98 .. 17902
1,790,107 events total
2021-05-26 05:51:24 <steven1> that will only match Foo at the top level, I need to find occurences anywhere in the tree
2021-05-26 05:51:57 <steven1> there are other things like Case, Let, etc. the pattern I'm talking about could appear anywhere
2021-05-26 05:51:58 <dy> Ah yeah good point. A few ways to go about that.
2021-05-26 05:52:16 <dy> 1. Have a Foldable or similar instance to make the default case automatically peel off a layer and recurse.
2021-05-26 05:52:27 <dy> 2. Some weird split-apply-map type dealio.
2021-05-26 05:52:32 <steven1> yep I have the foldable instance
2021-05-26 05:53:31 <steven1> but seems that when I fold, I also need to reconstruct the expr as I go back up. And I don't know if it's actually possible, since some of the constructors take two sub-expressions for example
2021-05-26 05:53:34 × Tomurb quits (~tom@92-17.net.optinet.cz) (Ping timeout: 264 seconds)
2021-05-26 05:53:47 <steven1> it makes sense to reconstruct a list with a fold but not a tree
2021-05-26 05:53:55 <steven1> at least that's what it seems like
2021-05-26 05:53:59 <c_wraith> trees can be folded just fine.
2021-05-26 05:54:00 <dy> Right, or it could be that your rewrite removes a subtree.
2021-05-26 05:54:04 <dy> Or adds new ones.
2021-05-26 05:54:09 <steven1> yep
2021-05-26 05:54:10 <dy> Which also now need to be traversed.
2021-05-26 05:54:26 <steven1> well if it helps let's say the new ones don't necessarily have to be traversed
2021-05-26 05:54:32 <dy> There's probably a clever way to do this with Traversable or such, but I think just writing a normal function would be easier.
2021-05-26 05:54:53 <dy> yes, you'll have to add a default "do nothing and just recurse" case as you expand your Expr type, but that's likely way less work that implementing and debugging all of this.
2021-05-26 05:54:53 Heffalump joins (~ganesh@urchin.earth.li)
2021-05-26 05:54:58 <dy> Which, I think, amounts to a complete macro system.
2021-05-26 05:55:20 <dy> If this is a toy language or personal project, just KiSS.
2021-05-26 05:55:29 <c_wraith> I mean, you probably would want a paramorphism rather than a catamorphism, but there's no challenge using them for local rewrites.
2021-05-26 05:56:15 <c_wraith> on the other hand, some of the Plated tools in lens might also be interesting
2021-05-26 05:56:26 <steven1> yeah Plated is for recursion schemes right?
2021-05-26 05:56:39 <c_wraith> not exactly. Related, but not the same
2021-05-26 05:57:19 <steven1> https://hackage.haskell.org/package/lens-5.0.1/docs/Control-Lens-Combinators.html#v:rewrite
2021-05-26 05:57:22 <steven1> seems very related
2021-05-26 05:57:40 <c_wraith> yeah, the rewrite* family of functions are all variations on this idea
2021-05-26 05:58:09 <dy> c_wraith here with the better help
2021-05-26 05:58:21 <dy> I didn't realize rewrites were in lens! Neat.
2021-05-26 05:58:42 gabriel joins (~gabriel@84-114-119-49.cable.dynamic.surfer.at)
2021-05-26 05:58:59 × TheCoffeMaker quits (~TheCoffeM@user/thecoffemaker) (Ping timeout: 252 seconds)
2021-05-26 05:59:50 × Guest10 quits (~Guest10@113.172.47.69) (Quit: Connection closed)
2021-05-26 06:00:33 meejah joins (~meejah@rutas.meejah.ca)
2021-05-26 06:01:26 ddellacosta joins (~ddellacos@86.106.121.88)
2021-05-26 06:01:28 bah joins (~bah@s176125235106.blix.com)
2021-05-26 06:02:01 <steven1> only thing is that we may not want to take the dependency on lens. I wonder is there any resource that shows how to derive this Plated concept from first principles, then maybe I can try to implement it myself for this specific data type? Hopefully I'm not asking too much here :)
2021-05-26 06:02:17 <steven1> or just some info on Plated, since I've only heard of it briefly
2021-05-26 06:02:18 <c_wraith> that idea is extracted from libraries like uniplate and biplate
2021-05-26 06:02:34 <c_wraith> so if you want smaller dependencies, they're options
2021-05-26 06:02:49 TheCoffeMaker joins (~TheCoffeM@user/thecoffemaker)
2021-05-26 06:03:29 bfrk joins (~Thunderbi@200116b8453bc10024c96ca01cd76d14.dip.versatel-1u1.de)
2021-05-26 06:03:35 <steven1> ok, I'll take a look
2021-05-26 06:03:46 <steven1> thanks a lot c_wraith dy !
2021-05-26 06:04:03 acid joins (~acid@user/acid)
2021-05-26 06:04:57 bontaq parts (~user@ool-18e47f8d.dyn.optonline.net) (ERC (IRC client for Emacs 26.3))
2021-05-26 06:05:07 bontaq joins (~user@ool-18e47f8d.dyn.optonline.net)
2021-05-26 06:06:03 × ddellacosta quits (~ddellacos@86.106.121.88) (Ping timeout: 272 seconds)
2021-05-26 06:07:13 × slowButPresent quits (~slowButPr@user/slowbutpresent) (Quit: leaving)
2021-05-26 06:08:05 <steven1> so looking at Uniplate, it looks like I only need to implement one function for my datatype that does a transformation like this
2021-05-26 06:08:12 <steven1> uniplate (Add (Val 1) (Neg (Val 2))) = ([Val 1, Neg (Val 2)], \[a,b] -> Add a b)
2021-05-26 06:08:21 plv joins (~pasha@pool-71-125-13-187.nycmny.fios.verizon.net)
2021-05-26 06:08:23 <steven1> and everything else should follow from that I guess
2021-05-26 06:09:50 × ksqsf quits (~textual@67.209.186.120.16clouds.com) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-05-26 06:10:46 noddy joins (~self@c6a7c791.vpn.njalla.net)
2021-05-26 06:10:48 atwm joins (~andrew@19-193-28-81.ftth.cust.kwaoo.net)
2021-05-26 06:11:38 × doc2 quits (~doc@14-201-241-128.tpgi.com.au) (Ping timeout: 265 seconds)
2021-05-26 06:12:43 zcli joins (~user@2601:641:8080:71c0:aca9:4ce:b448:a8fa)
2021-05-26 06:12:59 × gabriel quits (~gabriel@84-114-119-49.cable.dynamic.surfer.at) (Quit: Leaving)
2021-05-26 06:13:33 bah_ joins (~bah@s176125235116.blix.com)
2021-05-26 06:14:43 xnyhps joins (~xnyhps@2a02:2770:3:0:216:3eff:fe67:3288)
2021-05-26 06:15:15 × bah quits (~bah@s176125235106.blix.com) (Ping timeout: 264 seconds)
2021-05-26 06:15:37 bah_ is now known as bah
2021-05-26 06:15:46 × atwm quits (~andrew@19-193-28-81.ftth.cust.kwaoo.net) (Ping timeout: 264 seconds)
2021-05-26 06:17:48 doc2 joins (~doc@14-201-241-128.tpgi.com.au)
2021-05-26 06:18:15 × zcli quits (~user@2601:641:8080:71c0:aca9:4ce:b448:a8fa) (Quit: ERC (IRC client for Emacs 27.1))
2021-05-26 06:18:34 × plv quits (~pasha@pool-71-125-13-187.nycmny.fios.verizon.net) (Quit: Connection closed)
2021-05-26 06:18:45 × Bartosz quits (~textual@50.35.220.89) (Quit: Textual IRC Client: www.textualapp.com)
2021-05-26 06:19:58 ddellacosta joins (~ddellacos@89.46.62.76)
2021-05-26 06:20:01 wirtshutter joins (~wirtshutt@190.193.215.9)
2021-05-26 06:20:04 × yumaikas- quits (~yumaikas@2601:281:c700:4240:fd30:c8d2:2412:4375) (Ping timeout: 244 seconds)
2021-05-26 06:20:04 Guest11 joins (~textual@146.212.240.255)
2021-05-26 06:22:51 berberman_ joins (~berberman@user/berberman)
2021-05-26 06:23:34 × berberman quits (~berberman@user/berberman) (Ping timeout: 264 seconds)
2021-05-26 06:23:47 <Axman6> I've never seen the rewrite parts of lens before, how exciting! I've used the partsOf template party trick many times but it's nice to see there's lots of ways to do crazy things
2021-05-26 06:23:51 ignis joins (~ignisf@user/ignis)
2021-05-26 06:24:54 × ddellacosta quits (~ddellacos@89.46.62.76) (Ping timeout: 264 seconds)
2021-05-26 06:25:43 coot joins (~coot@37.30.49.19.nat.umts.dynamic.t-mobile.pl)
2021-05-26 06:26:00 <steven1> Axman6: I'm curious, what's the trick?
2021-05-26 06:26:08 × haskman quits (~haskman@171.61.174.98) (Ping timeout: 265 seconds)
2021-05-26 06:26:11 danso joins (~danso@23-233-111-52.cpe.pppoe.ca)
2021-05-26 06:26:14 GIANTWORLDKEEPER joins (~pjetcetal@2.95.204.25)
2021-05-26 06:26:20 julm joins (~julm@user/julm)
2021-05-26 06:27:54 <Axman6> % (Just "Hello","world!", ["Here","are","some","strings"]) & partsOf template %~ (reverse :: [Char] -> [Char])
2021-05-26 06:27:54 <yahb> Axman6: (Just "sgnir","tsemos",["erae","reH","!dlr","owolleH"])
2021-05-26 06:28:07 <Axman6> % (Just "Hello","world!", ["Here","are","some","strings"]) & partsOf template %~ (reverse :: [[Char]] -> [[Char]])
2021-05-26 06:28:07 <yahb> Axman6: (Just "strings","some",["are","Here","world!","Hello"])
2021-05-26 06:29:00 chele joins (~chele@user/chele)
2021-05-26 06:29:14 <steven1> wow
2021-05-26 06:29:34 <Axman6> % (Just "Hello","world!", ["Here","are","some","strings"]) & partsOf template %~ (reverse :: [[[Char]]] -> [[[Char]]])
2021-05-26 06:29:34 <yahb> Axman6: (Just "Hello","world!",["Here","are","some","strings"])
2021-05-26 06:30:10 <Axman6> % (Just "Hello","world!", ["Here","are","some","strings"]) & partsOf template %~ (map reverse :: [[[Char]]] -> [[[Char]]])
2021-05-26 06:30:10 <yahb> Axman6: (Just "Hello","world!",["strings","some","are","Here"])
2021-05-26 06:30:38 <steven1> and apparently template is similar to uniplate https://hackage.haskell.org/package/lens-5.0.1/docs/Data-Data-Lens.html#v:template
2021-05-26 06:30:43 chddr joins (~Thunderbi@91.226.34.182)
2021-05-26 06:30:52 imdoor joins (~imdoor@balticom-142-78-50.balticom.lv)
2021-05-26 06:31:05 <Axman6> yeah I have never had a good idea of what the differences are
2021-05-26 06:31:28 <Axman6> it's a party trick, I don't need to understand it :)
2021-05-26 06:31:58 <Axman6> but it does open up some really interesting possibilities, you can do things like apply a function to all strings which are URLs across a whole structure
2021-05-26 06:35:58 Heffalump parts (~ganesh@urchin.earth.li) ()
←Prev  Next→
Page 1 .. 88 89 90 91 92 93 94 95 96 97 98 .. 17902

All times are in UTC.