-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run checkEncoder with template haskell #1087
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
module Backend where | ||
|
||
import Common.Route | ||
import Common.Route.Checked | ||
import Data.Functor.Identity | ||
import Obelisk.Backend | ||
import Obelisk.Route | ||
|
||
backend :: Backend BackendRoute FrontendRoute | ||
backend = Backend | ||
{ _backend_run = \serve -> serve $ const $ return () | ||
, _backend_routeEncoder = fullRouteEncoder | ||
, _backend_routeEncoder = hoistCheck (pure . runIdentity) validFullEncoder | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
|
||
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} | ||
|
||
module Common.Route.Checked where | ||
|
||
import Data.Functor.Identity | ||
import qualified Data.Text as Text | ||
import Obelisk.Route | ||
|
||
import Common.Route | ||
|
||
case fullRouteEncoder of | ||
Left err -> error $ Text.unpack err | ||
Right _ -> | ||
[d| | ||
validFullEncoder :: Encoder Identity Identity (R (FullRoute BackendRoute FrontendRoute)) PageName | ||
Right validFullEncoder = fullRouteEncoder | ||
|] | ||
Comment on lines
+14
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't do this directly in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn't able to pull this into a DRY util as there's no way to get a |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
import Common.Route.Checked | ||
import Frontend | ||
import Common.Route | ||
import Obelisk.Frontend | ||
import Obelisk.Route.Frontend | ||
import Reflex.Dom | ||
|
||
main :: IO () | ||
main = do | ||
let Right validFullEncoder = checkEncoder fullRouteEncoder | ||
run $ runFrontend validFullEncoder frontend | ||
main = run $ runFrontend validFullEncoder frontend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could just be
_backend_routeEncoder = validFullEncoder
but that's a breaking change, probably best to get adoption first (assuming we merge this)