obelisk
obelisk copied to clipboard
[Breaking] Allow full routes for RouteToUrl in obelisk widgets
There's currently no type-safe way to obtain a url for a backend route on frontend widgets. Current workaround is to do
Right validEncoder = checkEncoder fullRouteEncoder
on the frontend and use renderBackendRoute
.
This PR makes ObeliskWidget
provide RouteToUrl
for the full route, but breaks backwards compatibility.
If only frontend routes are used, apps can simply provide an adapter at the root
_frontend_body = do
...
fullRouteToUrl <- askRouteToUrl
let frontendRouteToUrl = fullRouteToUrl . hoistR (FullRoute_Frontend . ObeliskRoute_App)
runRouteToUrlT myApp frontendRouteToUrl
but to actually use this for backend routes, one needs to propagate RouteToUrl
constraints throughout the app, and adjust the arguments of all the routeLink
family of widgets. Maybe some local
equivalent for RouteToUrl
would make the transition smoother by allowing an easy way to gradually rollout the expanded functionality.
I have:
- [x] Based work on latest
develop
branch - [ ] Followed the contribution guide
- [ ] Looked for lint in my changes with
hlint .
(lint found code you did not write can be left alone) - [ ] Run the test suite:
$(nix-build -A selftest --no-out-link)
- [ ] Updated the changelog
- [ ] (Optional) Run CI tests locally:
nix-build release.nix -A build.x86_64-linux --no-out-link
(orx86_64-darwin
on macOS)