I have a function called:
mapRouteEncoder ::
Prism' FilePath FilePath ->
Prism' r1 r2 ->
(b -> a) ->
RouteEncoder a r1 ->
RouteEncoder b r2
This function is often used by specifying "identity" prisms (if we can call it that) in the first two arguments because only the 3rd function is specified, viz.:
stringRouteEncoder
& mapRouteEncoder (prism' id Just) (prism' id Just) changeModel
I use optics-core, and is there anything in that library to replace prism' id Just something more idiomatic?
I'm not familiar with the idioms for that package, but I'd be tempted to use
castOptic equalityto turn the identityIsointo aPrism. That seems to get the idea across pretty well. However, I would expect that in most contexts you wouldn't actually need to convert it to aPrism; you can presumably use polymorphic functions (likepreviewandreview) that will accept anIsoas well as aPrism.In your case, I suspect the right approach would be to write something like