git.iko.soy/typeable/servant-reflex
on master help sign in
Discover by type error that our current type scheme won't work - we need an associated type like Final, and probably another typecclass parameter to hold the MonadWidget t m's m
ffec9a3Greg Hale
src/Servant/Common/Req.hs+3−3
@@ -67,9 +67,9 @@ data Req = Req
67defReq :: Req
67defReq :: Req
68defReq = Req "" [] Nothing [] []
68defReq = Req "" [] Nothing [] []
69
69
70−-- appendToPath :: String -> Req -> Req
70+appendToPath :: String -> Req -> Req
71−-- appendToPath p req =
71+appendToPath p req =
72−-- req { reqPath = reqPath req ++ "/" ++ p }
72+ req { reqPath = reqPath req ++ "/" ++ p }
73
73
74-- appendToQueryString :: Text -- ^ param name
74-- appendToQueryString :: Text -- ^ param name
75-- -> Maybe Text -- ^ param value
75-- -> Maybe Text -- ^ param value
src/Servant/Reflex.hs+11−14
@@ -63,16 +63,14 @@ import Reflex.Dom.Xhr
63client :: HasReflexClient layout
63client :: HasReflexClient layout
64 => Proxy layout
64 => Proxy layout
65 -> BaseUrl
65 -> BaseUrl
66−-- -> Client (Input layout) (Output layout)
66+ -> Client (Input layout) (Output layout)
67− -> Client layout
68client p baseurl = clientWithRoute p defReq baseurl
67client p baseurl = clientWithRoute p defReq baseurl
69
68
70data a ::> b = a ::> b deriving (Eq,Ord,Show,Read)
69data a ::> b = a ::> b deriving (Eq,Ord,Show,Read)
71
70
72infixr 3 ::>
71infixr 3 ::>
73
72
74−
75−-- type Client ins outs = MonadWidget t m => Event t ins -> m (Event t (ins,outs))
73+type Client ins outs = MonadWidget t m => Event t ins -> m (Event t (ins,outs))
76
74
77-- | This class lets us define how each API combinator
75-- | This class lets us define how each API combinator
78-- influences the creation of an HTTP request. It's mostly
76-- influences the creation of an HTTP request. It's mostly
@@ -80,9 +78,10 @@ infixr 3 ::>
80class HasReflexClient layout where
78class HasReflexClient layout where
81 type Input layout :: *
79 type Input layout :: *
82 type Output layout :: *
80 type Output layout :: *
83− type Client layout :: *
81+ -- clientWithRoute :: MonadWidget t m => Proxy layout -> Req -> BaseUrl
84− type Client layout = MonadWidget t m => Event t (Input layout) -> m (Event t (Output layout))
82+ -- -> Event t (Input layout) -> m (Event t (Input layout, Output layout))
85− clientWithRoute :: MonadWidget t m => Proxy layout -> Req -> BaseUrl
83+ clientWithRoute :: MonadWidget t m
84+ => Proxy layout -> Req -> BaseUrl
86 -> Event t (Input layout) -> m (Event t (Input layout, Output layout))
85 -> Event t (Input layout) -> m (Event t (Input layout, Output layout))
87
86
88
87
@@ -174,11 +173,10 @@ instance
174-- > where host = BaseUrl Http "localhost" 8080
173-- > where host = BaseUrl Http "localhost" 8080
175instance (HasReflexClient a, HasReflexClient b) => HasReflexClient (a :<|> b) where
174instance (HasReflexClient a, HasReflexClient b) => HasReflexClient (a :<|> b) where
176 type Input (a :<|> b) = Input a :<|> Input b
175 type Input (a :<|> b) = Input a :<|> Input b
177− -- type Output (a :<|> b) = Output a :<|> Output b
176+ type Output (a :<|> b) = Output a :<|> Output b
178− type Client (a :<|> b) = (Client a :<|> Client b)
179− clientWithRoute Proxy req baseurl (a :<|> b) =
177+ clientWithRoute Proxy req baseurl (a :<|> b) = undefined
180− clientWithRoute (Proxy :: Proxy a) req baseurl a :<|>
178+-- clientWithRoute (Proxy :: Proxy a) req baseurl a :<|>
181− clientWithRoute (Proxy :: Proxy b) req baseurl b
179+-- clientWithRoute (Proxy :: Proxy b) req baseurl b
182
180
183-- ------------------------------------------------------------------------------
181-- ------------------------------------------------------------------------------
184-- -- | If you use a 'Capture' in one of your endpoints in your API,
182-- -- | If you use a 'Capture' in one of your endpoints in your API,
@@ -582,8 +580,7 @@ instance (HasReflexClient a, HasReflexClient b) => HasReflexClient (a :<|> b) wh
582-- | Make the querying function append @path@ to the request path.
580-- | Make the querying function append @path@ to the request path.
583instance (KnownSymbol path, HasReflexClient sublayout) => HasReflexClient (path :> sublayout) where
581instance (KnownSymbol path, HasReflexClient sublayout) => HasReflexClient (path :> sublayout) where
584 type Input (path :> sublayout) = Input sublayout
582 type Input (path :> sublayout) = Input sublayout
585− --type Output (path :> sublayout) = Output sublayout
583+ type Output (path :> sublayout) = Output sublayout
586− type Client (path :> sublayout) = Client sublayout
587 clientWithRoute Proxy req baseurl val =
584 clientWithRoute Proxy req baseurl val =
588 clientWithRoute (Proxy :: Proxy sublayout)
585 clientWithRoute (Proxy :: Proxy sublayout)
589 (appendToPath p req)
586 (appendToPath p req)