content: {-# LANGUAGE EmptyCase #-}
  {-# LANGUAGE FlexibleContexts #-}
  {-# LANGUAGE FlexibleInstances #-}
  {-# LANGUAGE GADTs #-}
  {-# LANGUAGE KindSignatures #-}
  {-# LANGUAGE LambdaCase #-}
  {-# LANGUAGE MultiParamTypeClasses #-}
  {-# LANGUAGE OverloadedStrings #-}
  {-# LANGUAGE RankNTypes #-}
  {-# LANGUAGE ScopedTypeVariables #-}
  {-# LANGUAGE TemplateHaskell #-}
  {-# LANGUAGE TypeFamilies #-}
  
  module Common.Route where
  
  import Data.Functor.Identity
  import Data.Text (Text)
  import Obelisk.Route
  import Obelisk.Route.TH
  
  data BackendRoute :: * -> * where
    BackendRoute_Missing :: BackendRoute ()
    BackendRoute_GetData :: BackendRoute ()
  
  data FrontendRoute :: * -> * where
    FrontendRoute_Home :: FrontendRoute ()
  
  fullRouteEncoder ::
    Encoder (Either Text) Identity (R (FullRoute BackendRoute FrontendRoute)) PageName
  fullRouteEncoder =
    mkFullRouteEncoder
      (FullRoute_Backend BackendRoute_Missing :/ ())
      ( \case
          BackendRoute_Missing -> PathSegment "missing" $ unitEncoder mempty
          BackendRoute_GetData -> PathSegment "get-data" $ unitEncoder mempty
      )
      ( \case
          FrontendRoute_Home -> PathEnd $ unitEncoder mempty
      )
  
  concat
    <$> mapM
      deriveRouteComponent
      [ ''FrontendRoute,
        ''BackendRoute
      ]
  