on develop help sign in
Fix Xhr and WebSocket on IOS (nontemplate haskell)
commit68150eb7b879e7aa67c02858f71d7e97f8e4f852 authorHamish Mackenzie <Hamish.K.Mackenzie@googlemail.com> dateFri 23 Dec 2016, 22:17 (10 years ago) parente0c8dcb
3 files changed+86−1
reflex-dom-core/src/Reflex/Dom/WebSocket.hs+19 reflex-dom-core/src/Reflex/Dom/Xhr.hs+66 reflex-dom/reflex-dom.cabal+1−1
reflex-dom-core/src/Reflex/Dom/WebSocket.hs+19
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE AllowAmbiguousTypes #-}
23{-# LANGUAGE ConstraintKinds #-}
34{-# LANGUAGE DeriveDataTypeable #-}
@@ -15,7 +16,9 @@
1516{-# LANGUAGE RecursiveDo #-}
1617{-# LANGUAGE ScopedTypeVariables #-}
1718{-# LANGUAGE StandaloneDeriving #-}
19+#ifdef USE_TEMPLATE_HASKELL
1820{-# LANGUAGE TemplateHaskell #-}
21+#endif
1922{-# LANGUAGE TypeFamilies #-}
2023{-# LANGUAGE UndecidableInstances #-}
2124
@@ -125,4 +128,20 @@ webSocket' url config onRawMessage = do
125128 unless success $ atomically $ unGetTQueue payloadQueue payload
126129 return $ RawWebSocket eRecv eOpen eError eClose
127130
131+#ifdef USE_TEMPLATE_HASKELL
128132makeLensesWith (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 @@
55{-# LANGUAGE GADTs #-}
66{-# LANGUAGE MultiParamTypeClasses #-}
77{-# LANGUAGE OverloadedStrings #-}
8+#ifdef USE_TEMPLATE_HASKELL
89{-# LANGUAGE TemplateHaskell #-}
10+#endif
911module Reflex.Dom.Xhr
1012 ( XMLHttpRequest
1113 , XhrRequest (..)
@@ -301,8 +303,72 @@ decodeText = decode . BL.fromStrict . encodeUtf8
301303decodeXhrResponse :: FromJSON a => XhrResponse -> Maybe a
302304decodeXhrResponse = join . fmap decodeText . _xhrResponse_responseText
303305
306+#ifdef USE_TEMPLATE_HASKELL
304307concat <$> mapM makeLenses
305308 [ ''XhrRequest
306309 , ''XhrRequestConfig
307310 , ''XhrResponse
308311 ]
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
2828 reflex == 0.5.*,
2929 reflex-dom-core >=0.4 && <0.5,
3030 text == 1.2.*
31− if os(osx)
31+ if os(osx) || os(ios)
3232 build-depends:
3333 jsaddle-wkwebview
3434 else