nomeata / haskell-rec-def

APIs for more recursive definitions
https://haskell-rec-def.nomeata.de/
BSD 2-Clause "Simplified" License
19 stars 2 forks source link

Possible to add `Data.Recursive.Map.map` function? #10

Closed evanrelf closed 1 year ago

evanrelf commented 1 year ago

containers has Data.Map.map, which allows changing the type of the values:

map :: (a -> b) -> Map k a -> Map k b

Is this possible in rec-def?


For context, I was working on a solution for Advent of Code 2015 day 7 (link to my solution if you're curious). It relies heavily on mutual recursion and laziness.

My current solution is a little crude - I was trying to only use base - so I thought using rec-def's RMap could be nice to polish it up a little bit. But I need to change the phantom type on my Signal GADT, and I didn't see a way to change the type of values in an RMap...

nomeata commented 1 year ago

Yes, good point! This function (and also mapWithKeys) is perfectly monotonic, so I should add it. Give me a few minutes.

I’m very curious if you can make good use of RMap.

nomeata commented 1 year ago

Released as 0.2.2. Let me know how it goes!