Add Ask.map and Ask.map!
ceedubs opened this issue · comments
Summary
This adds Ask.map!
and a delayed Ask.map
, which map the input to an Ask
computation. This is analogous to Haskell's MonadReader.local
, but more flexible, since it can map the type parameter. I thought about naming it Ask.local
, which might help some Haskeller's find it, but I didn't think that was a particularly obvious name for FP newcomers. Most (maybe all?) of the other map
functions in base are covariant maps, while this is a contravariant map. But Ask.map
should be unambiguous since there can't be a covariant map
for Ask
(other than function composition on the output, but that's already covered by >>
), and I don't think that naming it Ask.contraMap
would be helpful to anyone.
Notable definitions:
Changes
Here's what would change in the current namespace after the merge:
Added definitions:
1. abilities.Ask.map.doc : Doc
2. abilities.Ask.map!.doc : Doc
3. abilities.Ask.map!.example : Text
4. abilities.Ask.map : (a ->{g1} b) -> '{g2, Ask b} r -> '{g1, g2, Ask a} r
5. abilities.Ask.map! : (a ->{g1} b) -> '{g2, Ask b} r ->{g1, g2, Ask a} r
6. abilities.Ask.map!.test : [test.Result] (+1 metadata)
This is now in /main
. Thanks! 🌈⭐