Skip to content

Commit

Permalink
Comply with -Werror
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfmpe committed May 31, 2024
1 parent 90de70b commit 0820954
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/backend/src/Obelisk/Backend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import qualified Data.ByteString.Char8 as BSC8
import Data.Default (Default (..))
import Data.Dependent.Sum
import Data.Functor.Identity
import Data.Kind (Type)
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Text (Text)
Expand Down Expand Up @@ -202,7 +203,7 @@ data StaticAssets = StaticAssets
}
deriving (Show, Read, Eq, Ord)

data GhcjsAppRoute :: (* -> *) -> * -> * where
data GhcjsAppRoute :: (Type -> Type) -> Type -> Type where
GhcjsAppRoute_App :: appRouteComponent a -> GhcjsAppRoute appRouteComponent a
GhcjsAppRoute_Resource :: GhcjsAppRoute appRouteComponent [Text]

Expand Down
2 changes: 1 addition & 1 deletion lib/frontend/src/Obelisk/Frontend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Obelisk.Frontend
( ObeliskWidget
Expand Down Expand Up @@ -207,7 +208,6 @@ runFrontendWithConfigsAndCurrentRoute mode configs validFullEncoder frontend = d
, PrimMonad m
, MonadSample DomTimeline (Performable m)
, DOM.MonadJSM m
, MonadFix (Client (HydrationDomBuilderT s DomTimeline m))
, MonadFix (Performable m)
, MonadFix m
, Prerender DomTimeline (HydrationDomBuilderT s DomTimeline m)
Expand Down
1 change: 1 addition & 0 deletions lib/frontend/src/Obelisk/Frontend/Cookie.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

module Obelisk.Frontend.Cookie where
Expand Down
13 changes: 7 additions & 6 deletions lib/route/src/Obelisk/Route.hs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ import Data.Functor.Sum
import Data.GADT.Compare
import Data.GADT.Compare.TH
import Data.GADT.Show
import Data.Kind (Type)
import Data.List.NonEmpty (NonEmpty (..))
import Data.Map (Map)
import qualified Data.Map as Map
Expand Down Expand Up @@ -961,31 +962,31 @@ handleEncoder recover e = Encoder $ do

-- | The typical full route type comprising all of an Obelisk application's routes.
-- Parameterised by the top level GADTs that define backend and frontend routes, respectively.
data FullRoute :: (* -> *) -> (* -> *) -> * -> * where
data FullRoute :: (Type -> Type) -> (Type -> Type) -> Type -> Type where
FullRoute_Backend :: br a -> FullRoute br fr a
FullRoute_Frontend :: ObeliskRoute fr a -> FullRoute br fr a

-- | A type which can represent Obelisk-specific resource routes, in addition to application specific routes which serve your
-- frontend.
data ObeliskRoute :: (* -> *) -> * -> * where
data ObeliskRoute :: (Type -> Type) -> Type -> Type where
-- We need to have the `f a` as an argument here, because otherwise we have no way to specifically check for overlap between us and the given encoder
ObeliskRoute_App :: f a -> ObeliskRoute f a
ObeliskRoute_Resource :: ResourceRoute a -> ObeliskRoute f a

-- | A type representing the various resource routes served by Obelisk. These can in principle map to any physical routes you want,
-- but sane defaults are provided by 'resourceRouteSegment'
data ResourceRoute :: * -> * where
data ResourceRoute :: Type -> Type where
ResourceRoute_Static :: ResourceRoute [Text] -- This [Text] represents the *path in our static files directory*, not necessarily the URL path that the asset gets served at (although that will often be "/static/this/text/thing")
ResourceRoute_Ghcjs :: ResourceRoute [Text]
ResourceRoute_JSaddleWarp :: ResourceRoute (R JSaddleWarpRoute)
ResourceRoute_Version :: ResourceRoute ()

data JSaddleWarpRoute :: * -> * where
data JSaddleWarpRoute :: Type -> Type where
JSaddleWarpRoute_JavaScript :: JSaddleWarpRoute ()
JSaddleWarpRoute_WebSocket :: JSaddleWarpRoute ()
JSaddleWarpRoute_Sync :: JSaddleWarpRoute [Text]

data IndexOnlyRoute :: * -> * where
data IndexOnlyRoute :: Type -> Type where
IndexOnlyRoute :: IndexOnlyRoute ()

concat <$> mapM deriveRouteComponent
Expand Down Expand Up @@ -1112,7 +1113,7 @@ someSumEncoder = Encoder $ pure $ EncoderImpl
Right (Some r) -> Some (InR r)
}

data Void1 :: * -> * where {}
data Void1 :: Type -> Type where {}

instance UniverseSome Void1 where
universeSome = []
Expand Down
10 changes: 5 additions & 5 deletions lib/route/src/Obelisk/Route/Frontend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ instance Adjustable t m => Adjustable t (RoutedT t r m) where
traverseDMapWithKeyWithAdjust f a0 a' = RoutedT $ traverseDMapWithKeyWithAdjust (\k v -> coerce $ f k v) (coerce a0) $ coerce a'
traverseDMapWithKeyWithAdjustWithMove f a0 a' = RoutedT $ traverseDMapWithKeyWithAdjustWithMove (\k v -> coerce $ f k v) (coerce a0) $ coerce a'

instance (Monad m, MonadQuery t vs m) => MonadQuery t vs (RoutedT t r m) where
instance MonadQuery t vs m => MonadQuery t vs (RoutedT t r m) where
tellQueryIncremental = lift . tellQueryIncremental
askQueryResult = lift askQueryResult
queryIncremental = lift . queryIncremental
Expand Down Expand Up @@ -281,13 +281,13 @@ eitherRouted :: (Reflex t, MonadFix m, MonadHold t m) => RoutedT t (Either (Dyna
eitherRouted r = RoutedT $ ReaderT $ runRoutedT r <=< eitherDyn

-- | WARNING: The input 'Dynamic' must be fully constructed when this is run
strictDynWidget :: (MonadSample t m, MonadHold t m, Adjustable t m) => (a -> m b) -> RoutedT t a m (Dynamic t b)
strictDynWidget :: (MonadHold t m, Adjustable t m) => (a -> m b) -> RoutedT t a m (Dynamic t b)
strictDynWidget f = RoutedT $ ReaderT $ \r -> do
r0 <- sample $ current r
(result0, result') <- runWithReplace (f r0) $ f <$> updated r
holdDyn result0 result'

strictDynWidget_ :: (MonadSample t m, MonadHold t m, Adjustable t m) => (a -> m ()) -> RoutedT t a m ()
strictDynWidget_ :: (MonadHold t m, Adjustable t m) => (a -> m ()) -> RoutedT t a m ()
strictDynWidget_ f = RoutedT $ ReaderT $ \r -> do
r0 <- sample $ current r
(_, _) <- runWithReplace (f r0) $ f <$> updated r
Expand Down Expand Up @@ -368,7 +368,7 @@ instance (MonadHold t m, Adjustable t m) => Adjustable t (SetRouteT t r m) where
traverseDMapWithKeyWithAdjust f a0 a' = SetRouteT $ traverseDMapWithKeyWithAdjust (\k v -> coerce $ f k v) (coerce a0) $ coerce a'
traverseDMapWithKeyWithAdjustWithMove f a0 a' = SetRouteT $ traverseDMapWithKeyWithAdjustWithMove (\k v -> coerce $ f k v) (coerce a0) $ coerce a'

instance (Monad m, MonadQuery t vs m) => MonadQuery t vs (SetRouteT t r m) where
instance (MonadQuery t vs m) => MonadQuery t vs (SetRouteT t r m) where
tellQueryIncremental = lift . tellQueryIncremental
askQueryResult = lift askQueryResult
queryIncremental = lift . queryIncremental
Expand Down Expand Up @@ -446,7 +446,7 @@ instance Adjustable t m => Adjustable t (RouteToUrlT r m) where
traverseDMapWithKeyWithAdjust f a0 a' = RouteToUrlT $ traverseDMapWithKeyWithAdjust (\k v -> coerce $ f k v) (coerce a0) $ coerce a'
traverseDMapWithKeyWithAdjustWithMove f a0 a' = RouteToUrlT $ traverseDMapWithKeyWithAdjustWithMove (\k v -> coerce $ f k v) (coerce a0) $ coerce a'

instance (Monad m, MonadQuery t vs m) => MonadQuery t vs (RouteToUrlT r m) where
instance MonadQuery t vs m => MonadQuery t vs (RouteToUrlT r m) where
tellQueryIncremental = lift . tellQueryIncremental
askQueryResult = lift askQueryResult
queryIncremental = lift . queryIncremental
Expand Down
5 changes: 3 additions & 2 deletions skeleton/common/src/Common/Route.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ import Control.Category

import Data.Text (Text)
import Data.Functor.Identity
import Data.Kind (Type)

import Obelisk.Route
import Obelisk.Route.TH

data BackendRoute :: * -> * where
data BackendRoute :: Type -> Type where
-- | Used to handle unparseable routes.
BackendRoute_Missing :: BackendRoute ()
-- You can define any routes that will be handled specially by the backend here.
-- i.e. These do not serve the frontend, but do something different, such as serving static files.

data FrontendRoute :: * -> * where
data FrontendRoute :: Type -> Type where
FrontendRoute_Main :: FrontendRoute ()
-- This type is used to define frontend routes, i.e. ones for which the backend will serve the frontend.

Expand Down

0 comments on commit 0820954

Please sign in to comment.