@@ -71,28 +71,28 @@ qParamToQueryPart (QParamSome a) = Right (Just $ toQueryParam a)
7171qParamToQueryPart QNone = Right Nothing
7272qParamToQueryPart (QParamInvalid e) = Left e
7373
74−data QueryPart t = QueryPartParam (Behavior t (Either Text (Maybe Text)))
75− | QueryPartParams (Behavior t [Text])
76− | QueryPartFlag (Behavior t Bool)
74+data QueryPart t = QueryPartParam (Dynamic t (Either Text (Maybe Text)))
75+ | QueryPartParams (Dynamic t [Text])
76+ | QueryPartFlag (Dynamic t Bool)
7777
7878data Req t = Req
7979 { reqMethod :: Text
80− , reqPathParts :: [Behavior t (Either Text Text)]
80+ , reqPathParts :: [Dynamic t (Either Text Text)]
8181 , qParams :: [(Text, QueryPart t)]
82− , reqBody :: Maybe (Behavior t (Either Text (BL.ByteString, Text)))
82+ , reqBody :: Maybe (Dynamic t (Either Text (BL.ByteString, Text)))
8383 -- , reqAccept :: [MediaType] -- TODO ?
84− , headers :: [(Text, Behavior t Text)]
85− , authData :: Maybe (Behavior t (Maybe BasicAuthData))
84+ , headers :: [(Text, Dynamic t Text)]
85+ , authData :: Maybe (Dynamic t (Maybe BasicAuthData))
8686 }
8787
8888defReq :: Reflex t => Req t
8989defReq = Req "GET" [] [] Nothing [] Nothing
9090
91−prependToPathParts :: Reflex t => Behavior t (Either Text Text) -> Req t -> Req t
91+prependToPathParts :: Reflex t => Dynamic t (Either Text Text) -> Req t -> Req t
9292prependToPathParts p req =
9393 req { reqPathParts = p : reqPathParts req }
9494
95−addHeader :: (ToHttpApiData a, Reflex t) => Text -> Behavior t (Either Text a) -> Req t -> Req t
95+addHeader :: (ToHttpApiData a, Reflex t) => Text -> Dynamic t (Either Text a) -> Req t -> Req t
9696addHeader name val req = req { headers = headers req
9797 <> [(name, fmap (TE.decodeUtf8 . toHeader) val)]
9898-- <> [(name, (fmap . fmap) (decodeUtf8 . toHeader) val)]
@@ -115,19 +115,19 @@ performRequest :: forall t m.MonadWidget t m
115115performRequest reqMeth req reqHost trigger = do
116116
117117 -- Ridiculous functor-juggling! How to clean this up?
118− let t :: Behavior t [Either Text Text]
118+ let t :: Dynamic t [Either Text Text]
119119 t = sequence $ reverse $ reqPathParts req
120120
121− baseUrl :: Behavior t (Either Text Text)
122− baseUrl = Right . showBaseUrl <$> current reqHost
121+ baseUrl :: Dynamic t (Either Text Text)
122+ baseUrl = Right . showBaseUrl <$> reqHost
123123
124− urlParts :: Behavior t (Either Text [Text])
124+ urlParts :: Dynamic t (Either Text [Text])
125125 urlParts = fmap sequence t
126126
127− urlPath :: Behavior t (Either Text Text)
127+ urlPath :: Dynamic t (Either Text Text)
128128 urlPath = (fmap.fmap) (T.intercalate "/") urlParts
129129
130− queryPartString :: (Text, QueryPart t) -> Behavior t (Maybe (Either Text Text))
130+ queryPartString :: (Text, QueryPart t) -> Dynamic t (Maybe (Either Text Text))
131131 queryPartString (pName, qp) = case qp of
132132 QueryPartParam p -> ffor p $ \case
133133 Left e -> Just (Left e)
@@ -142,10 +142,10 @@ performRequest reqMeth req reqHost trigger = do
142142 False -> Nothing
143143
144144
145− queryPartStrings :: [Behavior t (Maybe (Either Text Text))]
145+ queryPartStrings :: [Dynamic t (Maybe (Either Text Text))]
146146 queryPartStrings = map queryPartString (qParams req)
147− queryPartStrings' = fmap (sequence . catMaybes) $ sequence queryPartStrings :: Behavior t (Either Text [Text])
148− queryString :: Behavior t (Either Text Text) =
147+ queryPartStrings' = fmap (sequence . catMaybes) $ sequence queryPartStrings :: Dynamic t (Either Text [Text])
148+ queryString :: Dynamic t (Either Text Text) =
149149 ffor queryPartStrings' $ \qs -> fmap (T.intercalate "&") qs
150150-- ffor queryPartStrings' $ \qs -> fmap (T.intercalate "&") (sequence qs)
151151 xhrUrl = (liftA3 . liftA3) (\a p q -> a </> if T.null q then p else p <> "?" <> q) baseUrl urlPath queryString
@@ -154,7 +154,7 @@ performRequest reqMeth req reqHost trigger = do
154154 x </> y | ("/" `T.isSuffixOf` x) || ("/" `T.isPrefixOf` y) = x <> y
155155 | otherwise = x <> "/" <> y
156156
157− xhrHeaders :: Behavior t [(Text, Text)]
157+ xhrHeaders :: Dynamic t [(Text, Text)]
158158 xhrHeaders = sequence $ ffor (headers req) $ \(hName, hVal) -> fmap (hName,) hVal
159159
160160 mkConfigBody :: [(Text,Text)] -> (Either Text (BL.ByteString, Text)) -> Either Text (XhrRequestConfig LT.Text)
@@ -165,7 +165,7 @@ performRequest reqMeth req reqHost trigger = do
165165 , _xhrRequestConfig_headers =
166166 Map.insert "Content-Type" bCT (_xhrRequestConfig_headers def)}
167167
168− xhrOpts :: Behavior t (Either Text (XhrRequestConfig LT.Text))
168+ xhrOpts :: Dynamic t (Either Text (XhrRequestConfig LT.Text))
169169 xhrOpts = case reqBody req of
170170 Nothing -> fmap (\h -> Right $ XhrRequestConfig
171171 (Map.fromList h) Nothing Nothing Nothing "") xhrHeaders
@@ -178,14 +178,14 @@ performRequest reqMeth req reqHost trigger = do
178178 { _xhrRequestConfig_user = Just $ TE.decodeUtf8 u
179179 , _xhrRequestConfig_password = Just $ TE.decodeUtf8 p}
180180
181− addAuth :: Behavior t (Either Text (XhrRequestConfig x)) -> Behavior t (Either Text (XhrRequestConfig x))
181+ addAuth :: Dynamic t (Either Text (XhrRequestConfig x)) -> Dynamic t (Either Text (XhrRequestConfig x))
182182 addAuth xhr = case authData req of
183183 Nothing -> xhr
184184 Just auth -> liftA2 mkAuth auth xhr
185185
186186 xhrReq = (liftA2 . liftA2) (\p opt -> XhrRequest reqMeth p opt) xhrUrl (addAuth xhrOpts)
187187
188− let reqs = tag xhrReq trigger
188+ let reqs = tagDyn xhrReq trigger
189189 okReqs = fmapMaybe (either (const Nothing) Just) reqs
190190 badReqs = fmapMaybe (either Just (const Nothing)) reqs
191191