on develop help sign in
Fix Xhr and WebSocket on IOS (nontemplate haskell)
68150ebHamish Mackenzie
reflex-dom-core/src/Reflex/Dom/WebSocket.hs+19
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE AllowAmbiguousTypes #-}
2{-# LANGUAGE AllowAmbiguousTypes #-}
2{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE DeriveDataTypeable #-}
4{-# LANGUAGE DeriveDataTypeable #-}
@@ -15,7 +16,9 @@
15{-# LANGUAGE RecursiveDo #-}
16{-# LANGUAGE RecursiveDo #-}
16{-# LANGUAGE ScopedTypeVariables #-}
17{-# LANGUAGE ScopedTypeVariables #-}
17{-# LANGUAGE StandaloneDeriving #-}
18{-# LANGUAGE StandaloneDeriving #-}
19+#ifdef USE_TEMPLATE_HASKELL
18{-# LANGUAGE TemplateHaskell #-}
20{-# LANGUAGE TemplateHaskell #-}
21+#endif
19{-# LANGUAGE TypeFamilies #-}
22{-# LANGUAGE TypeFamilies #-}
20{-# LANGUAGE UndecidableInstances #-}
23{-# LANGUAGE UndecidableInstances #-}
21
24
@@ -125,4 +128,20 @@ webSocket' url config onRawMessage = do
125 unless success $ atomically $ unGetTQueue payloadQueue payload
128 unless success $ atomically $ unGetTQueue payloadQueue payload
126 return $ RawWebSocket eRecv eOpen eError eClose
129 return $ RawWebSocket eRecv eOpen eError eClose
127
130
131+#ifdef USE_TEMPLATE_HASKELL
128makeLensesWith (lensRules & simpleLenses .~ True) ''WebSocketConfig
132makeLensesWith (lensRules & simpleLenses .~ True) ''WebSocketConfig
133+#else
134+
135+webSocketConfig_send :: Lens' (WebSocketConfig t a) (Event t [a])
136+webSocketConfig_send f (WebSocketConfig x1 x2 x3) = (\y -> WebSocketConfig y x2 x3) <$> f x1
137+{-# INLINE webSocketConfig_send #-}
138+
139+webSocketConfig_close :: Lens' (WebSocketConfig t a) (Event t (Word, Text))
140+webSocketConfig_close f (WebSocketConfig x1 x2 x3) = (\y -> WebSocketConfig x1 y x3) <$> f x2
141+{-# INLINE webSocketConfig_close #-}
142+
143+webSocketConfig_reconnect :: Lens' (WebSocketConfig t a) Bool
144+webSocketConfig_reconnect f (WebSocketConfig x1 x2 x3) = (\y -> WebSocketConfig x1 x2 y) <$> f x3
145+{-# INLINE webSocketConfig_reconnect #-}
146+
147+#endif
reflex-dom-core/src/Reflex/Dom/Xhr.hs+66
@@ -5,7 +5,9 @@
5{-# LANGUAGE GADTs #-}
5{-# LANGUAGE GADTs #-}
6{-# LANGUAGE MultiParamTypeClasses #-}
6{-# LANGUAGE MultiParamTypeClasses #-}
7{-# LANGUAGE OverloadedStrings #-}
7{-# LANGUAGE OverloadedStrings #-}
8+#ifdef USE_TEMPLATE_HASKELL
8{-# LANGUAGE TemplateHaskell #-}
9{-# LANGUAGE TemplateHaskell #-}
10+#endif
9module Reflex.Dom.Xhr
11module Reflex.Dom.Xhr
10 ( XMLHttpRequest
12 ( XMLHttpRequest
11 , XhrRequest (..)
13 , XhrRequest (..)
@@ -301,8 +303,72 @@ decodeText = decode . BL.fromStrict . encodeUtf8
301decodeXhrResponse :: FromJSON a => XhrResponse -> Maybe a
303decodeXhrResponse :: FromJSON a => XhrResponse -> Maybe a
302decodeXhrResponse = join . fmap decodeText . _xhrResponse_responseText
304decodeXhrResponse = join . fmap decodeText . _xhrResponse_responseText
303
305
306+#ifdef USE_TEMPLATE_HASKELL
304concat <$> mapM makeLenses
307concat <$> mapM makeLenses
305 [ ''XhrRequest
308 [ ''XhrRequest
306 , ''XhrRequestConfig
309 , ''XhrRequestConfig
307 , ''XhrResponse
310 , ''XhrResponse
308 ]
311 ]
312+#else
313+
314+xhrRequest_method :: Lens' (XhrRequest a) Text
315+xhrRequest_method f (XhrRequest x1 x2 x3) = (\y -> XhrRequest y x2 x3) <$> f x1
316+{-# INLINE xhrRequest_method #-}
317+
318+xhrRequest_url :: Lens' (XhrRequest a) Text
319+xhrRequest_url f (XhrRequest x1 x2 x3) = (\y -> XhrRequest x1 y x3) <$> f x2
320+{-# INLINE xhrRequest_url #-}
321+
322+xhrRequest_config :: Lens' (XhrRequest a) (XhrRequestConfig a)
323+xhrRequest_config f (XhrRequest x1 x2 x3) = (\y -> XhrRequest x1 x2 y) <$> f x3
324+{-# INLINE xhrRequest_config #-}
325+
326+xhrRequestConfig_headers :: Lens' (XhrRequestConfig a) (Map Text Text)
327+xhrRequestConfig_headers f (XhrRequestConfig x1 x2 x3 x4 x5 x6 x7) = (\y -> XhrRequestConfig y x2 x3 x4 x5 x6 x7) <$> f x1
328+{-# INLINE xhrRequestConfig_headers #-}
329+
330+xhrRequestConfig_user :: Lens' (XhrRequestConfig a) (Maybe Text)
331+xhrRequestConfig_user f (XhrRequestConfig x1 x2 x3 x4 x5 x6 x7) = (\y -> XhrRequestConfig x1 y x3 x4 x5 x6 x7) <$> f x2
332+{-# INLINE xhrRequestConfig_user #-}
333+
334+xhrRequestConfig_password :: Lens' (XhrRequestConfig a) (Maybe Text)
335+xhrRequestConfig_password f (XhrRequestConfig x1 x2 x3 x4 x5 x6 x7) = (\y -> XhrRequestConfig x1 x2 y x4 x5 x6 x7) <$> f x3
336+{-# INLINE xhrRequestConfig_password #-}
337+
338+xhrRequestConfig_responseType :: Lens' (XhrRequestConfig a) (Maybe XhrResponseType)
339+xhrRequestConfig_responseType f (XhrRequestConfig x1 x2 x3 x4 x5 x6 x7) = (\y -> XhrRequestConfig x1 x2 x3 y x5 x6 x7) <$> f x4
340+{-# INLINE xhrRequestConfig_responseType #-}
341+
342+xhrRequestConfig_sendData :: Lens' (XhrRequestConfig a) a
343+xhrRequestConfig_sendData f (XhrRequestConfig x1 x2 x3 x4 x5 x6 x7) = (\y -> XhrRequestConfig x1 x2 x3 x4 y x6 x7) <$> f x5
344+{-# INLINE xhrRequestConfig_sendData #-}
345+
346+xhrRequestConfig_withCredentials :: Lens' (XhrRequestConfig a) Bool
347+xhrRequestConfig_withCredentials f (XhrRequestConfig x1 x2 x3 x4 x5 x6 x7) = (\y -> XhrRequestConfig x1 x2 x3 x4 x5 y x7) <$> f x6
348+{-# INLINE xhrRequestConfig_withCredentials #-}
349+
350+xhrRequestConfig_responseHeaders :: Lens' (XhrRequestConfig a) XhrResponseHeaders
351+xhrRequestConfig_responseHeaders f (XhrRequestConfig x1 x2 x3 x4 x5 x6 x7) = (\y -> XhrRequestConfig x1 x2 x3 x4 x5 x6 y) <$> f x7
352+{-# INLINE xhrRequestConfig_responseHeaders #-}
353+
354+xhrResponse_status :: Lens' XhrResponse Word
355+xhrResponse_status f (XhrResponse x1 x2 x3 x4 x5) = (\y -> XhrResponse y x2 x3 x4 x5) <$> f x1
356+{-# INLINE xhrResponse_status #-}
357+
358+xhrResponse_statusText :: Lens' XhrResponse Text
359+xhrResponse_statusText f (XhrResponse x1 x2 x3 x4 x5) = (\y -> XhrResponse x1 y x3 x4 x5) <$> f x2
360+{-# INLINE xhrResponse_statusText #-}
361+
362+xhrResponse_response :: Lens' XhrResponse (Maybe XhrResponseBody)
363+xhrResponse_response f (XhrResponse x1 x2 x3 x4 x5) = (\y -> XhrResponse x1 x2 y x4 x5) <$> f x3
364+{-# INLINE xhrResponse_response #-}
365+
366+xhrResponse_responseText :: Lens' XhrResponse (Maybe Text)
367+xhrResponse_responseText f (XhrResponse x1 x2 x3 x4 x5) = (\y -> XhrResponse x1 x2 x3 y x5) <$> f x4
368+{-# INLINE xhrResponse_responseText #-}
369+
370+xhrResponse_headers :: Lens' XhrResponse (Map Text Text)
371+xhrResponse_headers f (XhrResponse x1 x2 x3 x4 x5) = (\y -> XhrResponse x1 x2 x3 x4 y) <$> f x5
372+{-# INLINE xhrResponse_headers #-}
373+
374+#endif
reflex-dom/reflex-dom.cabal+1−1
@@ -28,7 +28,7 @@ library
28 reflex == 0.5.*,
28 reflex == 0.5.*,
29 reflex-dom-core >=0.4 && <0.5,
29 reflex-dom-core >=0.4 && <0.5,
30 text == 1.2.*
30 text == 1.2.*
31− if os(osx)
31+ if os(osx) || os(ios)
32 build-depends:
32 build-depends:
33 jsaddle-wkwebview
33 jsaddle-wkwebview
34 else
34 else