@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE ConstraintKinds #-}
23{-# LANGUAGE DataKinds #-}
34{-# LANGUAGE DefaultSignatures #-}
@@ -12,6 +13,9 @@
1213{-# LANGUAGE RankNTypes #-}
1314{-# LANGUAGE RecursiveDo #-}
1415{-# LANGUAGE ScopedTypeVariables #-}
16+#ifdef USE_TEMPLATE_HASKELL
17+{-# LANGUAGE TemplateHaskell #-}
18+#endif
1519{-# LANGUAGE TypeFamilies #-}
1620{-# LANGUAGE UndecidableInstances #-}
1721module Reflex.Dom.Builder.Class
@@ -150,6 +154,7 @@ data TextNodeConfig t
150154 , _textNodeConfig_setContents :: Event t Text
151155 }
152156
157+#ifndef USE_TEMPLATE_HASKELL
153158textNodeConfig_initialContents :: Lens' (TextNodeConfig t) Text
154159textNodeConfig_initialContents f (TextNodeConfig a b) = (\a' -> TextNodeConfig a' b) <$> f a
155160{-# INLINE textNodeConfig_initialContents #-}
@@ -160,6 +165,7 @@ textNodeConfig_setContents :: Lens
160165 (Event t2 Text)
161166textNodeConfig_setContents f (TextNodeConfig a b) = (\b' -> TextNodeConfig a b') <$> f b
162167{-# INLINE textNodeConfig_setContents #-}
168+#endif
163169
164170instance (Reflex t) => Default (TextNodeConfig t) where
165171 {-# INLINABLE def #-}
@@ -225,6 +231,7 @@ data ElementConfig er t m
225231 , _elementConfig_eventSpec :: EventSpec (DomBuilderSpace m) er
226232 }
227233
234+#ifndef USE_TEMPLATE_HASKELL
228235elementConfig_namespace :: Lens' (ElementConfig er t m) (Maybe Namespace)
229236elementConfig_namespace f (ElementConfig a b c d) = (\a' -> ElementConfig a' b c d) <$> f a
230237{-# INLINE elementConfig_namespace #-}
@@ -245,6 +252,7 @@ elementConfig_eventSpec :: Lens
245252 (EventSpec (DomBuilderSpace m2) er2)
246253elementConfig_eventSpec f (ElementConfig a b c d) = (\d' -> ElementConfig a b c d') <$> f d
247254{-# INLINE elementConfig_eventSpec #-}
255+#endif
248256
249257data Element er d t
250258 = Element { _element_events :: EventSelector t (WrapArg er EventName) --TODO: EventSelector should have two arguments
@@ -256,6 +264,7 @@ data PlaceholderConfig above t m
256264 , _placeholderConfig_deleteSelf :: Event t ()
257265 }
258266
267+#ifndef USE_TEMPLATE_HASKELL
259268placeholderConfig_insertAbove :: Lens
260269 (PlaceholderConfig above1 t m1)
261270 (PlaceholderConfig above2 t m2)
@@ -266,6 +275,7 @@ placeholderConfig_insertAbove f (PlaceholderConfig a b) = (\a' -> PlaceholderCon
266275placeholderConfig_deleteSelf :: Lens' (PlaceholderConfig above t m) (Event t ())
267276placeholderConfig_deleteSelf f (PlaceholderConfig a b) = (\b' -> PlaceholderConfig a b') <$> f b
268277{-# INLINE placeholderConfig_deleteSelf #-}
278+#endif
269279
270280instance Reflex t => Default (PlaceholderConfig above t m) where
271281 {-# INLINABLE def #-}
@@ -287,6 +297,7 @@ data InputElementConfig er t m
287297 , _inputElementConfig_elementConfig :: ElementConfig er t m
288298 }
289299
300+#ifndef USE_TEMPLATE_HASKELL
290301inputElementConfig_initialValue :: Lens' (InputElementConfig er t m) Text
291302inputElementConfig_initialValue f (InputElementConfig a b c d e) = (\a' -> InputElementConfig a' b c d e) <$> f a
292303{-# INLINE inputElementConfig_initialValue #-}
@@ -306,6 +317,7 @@ inputElementConfig_elementConfig :: Lens
306317 (ElementConfig er2 t m2)
307318inputElementConfig_elementConfig f (InputElementConfig a b c d e) = (\e' -> InputElementConfig a b c d e') <$> f e
308319{-# INLINE inputElementConfig_elementConfig #-}
320+#endif
309321
310322instance (Reflex t, er ~ EventResult, DomBuilder t m) => Default (InputElementConfig er t m) where
311323 {-# INLINABLE def #-}
@@ -334,6 +346,7 @@ data TextAreaElementConfig er t m
334346 , _textAreaElementConfig_elementConfig :: ElementConfig er t m
335347 }
336348
349+#ifndef USE_TEMPLATE_HASKELL
337350textAreaElementConfig_initialValue :: Lens' (TextAreaElementConfig er t m) Text
338351textAreaElementConfig_initialValue f (TextAreaElementConfig a b c) = (\a' -> TextAreaElementConfig a' b c) <$> f a
339352{-# INLINE textAreaElementConfig_initialValue #-}
@@ -347,6 +360,7 @@ textAreaElementConfig_elementConfig :: Lens
347360 (ElementConfig er2 t m2)
348361textAreaElementConfig_elementConfig f (TextAreaElementConfig a b c) = (\c' -> TextAreaElementConfig a b c') <$> f c
349362{-# INLINE textAreaElementConfig_elementConfig #-}
363+#endif
350364
351365instance (Reflex t, er ~ EventResult, DomBuilder t m) => Default (TextAreaElementConfig er t m) where
352366 {-# INLINABLE def #-}
@@ -375,6 +389,7 @@ data RawElementConfig er t m = RawElementConfig
375389 , _rawElementConfig_eventSpec :: EventSpec (DomBuilderSpace m) er
376390 }
377391
392+#ifndef USE_TEMPLATE_HASKELL
378393rawElementConfig_modifyAttributes :: Lens
379394 (RawElementConfig er t1 m)
380395 (RawElementConfig er t2 m)
@@ -389,6 +404,7 @@ rawElementConfig_eventSpec :: Lens
389404 (EventSpec (DomBuilderSpace m2) er2)
390405rawElementConfig_eventSpec f (RawElementConfig a b) = (\b' -> RawElementConfig a b') <$> f b
391406{-# INLINE rawElementConfig_eventSpec #-}
407+#endif
392408
393409instance (Reflex t, DomSpace (DomBuilderSpace m)) => Default (RawElementConfig EventResult t m) where
394410 def = RawElementConfig
@@ -402,6 +418,7 @@ data SelectElementConfig er t m = SelectElementConfig
402418 , _selectElementConfig_elementConfig :: ElementConfig er t m
403419 }
404420
421+#ifndef USE_TEMPLATE_HASKELL
405422selectElementConfig_initialValue :: Lens' (SelectElementConfig er t m) Text
406423selectElementConfig_initialValue f (SelectElementConfig a b c) = (\a' -> SelectElementConfig a' b c) <$> f a
407424{-# INLINE selectElementConfig_initialValue #-}
@@ -415,6 +432,7 @@ selectElementConfig_elementConfig :: Lens
415432 (ElementConfig er2 t m2)
416433selectElementConfig_elementConfig f (SelectElementConfig a b c) = (\c' -> SelectElementConfig a b c') <$> f c
417434{-# INLINE selectElementConfig_elementConfig #-}
435+#endif
418436
419437instance (Reflex t, er ~ EventResult, DomBuilder t m) => Default (SelectElementConfig er t m) where
420438 def = SelectElementConfig
@@ -431,6 +449,18 @@ data SelectElement er d t = SelectElement
431449 , _selectElement_raw :: RawSelectElement d
432450 }
433451
452+#ifdef USE_TEMPLATE_HASKELL
453+concat <$> mapM makeLenses
454+ [ ''TextNodeConfig
455+ , ''ElementConfig
456+ , ''PlaceholderConfig
457+ , ''InputElementConfig
458+ , ''TextAreaElementConfig
459+ , ''SelectElementConfig
460+ , ''RawElementConfig
461+ ]
462+#endif
463+
434464class CanDeleteSelf t a | a -> t where
435465 deleteSelf :: Lens' a (Event t ())
436466