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
commitffec9a34446d4ee63169a61bc14743e75184a4a4 authorGreg Hale <imalsogreg@gmail.com> dateSun 7 Feb 2016, 17:49 (11 years ago) parent9b2b3fd
2 files changed+14−17
src/Servant/Common/Req.hs+3−3 src/Servant/Reflex.hs+11−14
src/Servant/Common/Req.hs+3−3
@@ -67,9 +67,9 @@ data Req = Req
6767defReq :: Req
6868defReq = Req "" [] Nothing [] []
6969
70−-- appendToPath :: String -> Req -> Req
71−-- appendToPath p req =
72−-- req { reqPath = reqPath req ++ "/" ++ p }
70+appendToPath :: String -> Req -> Req
71+appendToPath p req =
72+ req { reqPath = reqPath req ++ "/" ++ p }
7373
7474-- appendToQueryString :: Text -- ^ param name
7575-- -> Maybe Text -- ^ param value
src/Servant/Reflex.hs+11−14
@@ -63,16 +63,14 @@ import Reflex.Dom.Xhr
6363client :: HasReflexClient layout
6464 => Proxy layout
6565 -> BaseUrl
66−-- -> Client (Input layout) (Output layout)
67− -> Client layout
66+ -> Client (Input layout) (Output layout)
6867client p baseurl = clientWithRoute p defReq baseurl
6968
7069data a ::> b = a ::> b deriving (Eq,Ord,Show,Read)
7170
7271infixr 3 ::>
7372
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))
7674
7775-- | This class lets us define how each API combinator
7876-- influences the creation of an HTTP request. It's mostly
@@ -80,9 +78,10 @@ infixr 3 ::>
8078class HasReflexClient layout where
8179 type Input layout :: *
8280 type Output layout :: *
83− type Client layout :: *
84− type Client layout = MonadWidget t m => Event t (Input layout) -> m (Event t (Output layout))
85− clientWithRoute :: MonadWidget t m => Proxy layout -> Req -> BaseUrl
81+ -- clientWithRoute :: MonadWidget t m => Proxy layout -> Req -> BaseUrl
82+ -- -> Event t (Input layout) -> m (Event t (Input layout, Output layout))
83+ clientWithRoute :: MonadWidget t m
84+ => Proxy layout -> Req -> BaseUrl
8685 -> Event t (Input layout) -> m (Event t (Input layout, Output layout))
8786
8887
@@ -174,11 +173,10 @@ instance
174173-- > where host = BaseUrl Http "localhost" 8080
175174instance (HasReflexClient a, HasReflexClient b) => HasReflexClient (a :<|> b) where
176175 type Input (a :<|> b) = Input a :<|> Input b
177− -- type Output (a :<|> b) = Output a :<|> Output b
178− type Client (a :<|> b) = (Client a :<|> Client b)
179− clientWithRoute Proxy req baseurl (a :<|> b) =
180− clientWithRoute (Proxy :: Proxy a) req baseurl a :<|>
181− clientWithRoute (Proxy :: Proxy b) req baseurl b
176+ type Output (a :<|> b) = Output a :<|> Output b
177+ clientWithRoute Proxy req baseurl (a :<|> b) = undefined
178+-- clientWithRoute (Proxy :: Proxy a) req baseurl a :<|>
179+-- clientWithRoute (Proxy :: Proxy b) req baseurl b
182180
183181-- ------------------------------------------------------------------------------
184182-- -- | 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
582580-- | Make the querying function append @path@ to the request path.
583581instance (KnownSymbol path, HasReflexClient sublayout) => HasReflexClient (path :> sublayout) where
584582 type Input (path :> sublayout) = Input sublayout
585− --type Output (path :> sublayout) = Output sublayout
586− type Client (path :> sublayout) = Client sublayout
583+ type Output (path :> sublayout) = Output sublayout
587584 clientWithRoute Proxy req baseurl val =
588585 clientWithRoute (Proxy :: Proxy sublayout)
589586 (appendToPath p req)