blob: 3a974eddb7958cdb2c253afa232f8b6b0ea9dfb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
module Web.Routing.SafeRouting where
import Control.DeepSeq (NFData (..))
import Data.Kind (Constraint, Type)
import Data.Typeable (Typeable)
class FromHttpApiData a where
data PolyMap (c :: Type -> Constraint) (f :: Type -> Type) (a :: Type) where
PMNil :: PolyMap c f a
PMCons :: (Typeable p, c p) => f (p -> a) -> PolyMap c f a -> PolyMap c f a
rnfHelper :: (forall p. c p => f (p -> a) -> ()) -> PolyMap c f a -> ()
rnfHelper _ PMNil = ()
rnfHelper h (PMCons v pm) = h v `seq` rnfHelper h pm
data PathMap x =
PathMap [x] (PolyMap FromHttpApiData PathMap x)
instance NFData x => NFData (PathMap x) where
rnf (PathMap a b) = rnf a `seq` rnfHelper rnf b
|