on develop help sign in
Revert "Make HasAttributes more polymorphic"
204e4ecRyan Trinkle
src/Reflex/Dom/Widget/Basic.hs+9−7
@@ -1,4 +1,4 @@
1−{-# LANGUAGE ScopedTypeVariables, LambdaCase, ConstraintKinds, TypeFamilies, FlexibleContexts, MultiParamTypeClasses, FlexibleInstances, RecursiveDo, GADTs, DataKinds, RankNTypes, TemplateHaskell, FunctionalDependencies #-}
1+{-# LANGUAGE ScopedTypeVariables, LambdaCase, ConstraintKinds, TypeFamilies, FlexibleContexts, MultiParamTypeClasses, FlexibleInstances, RecursiveDo, GADTs, DataKinds, RankNTypes, TemplateHaskell #-}
2
2
3module Reflex.Dom.Widget.Basic where
3module Reflex.Dom.Widget.Basic where
4
4
@@ -651,11 +651,11 @@ emptyElWith' elementTag cfg = do
651elDynAttrNS' :: forall t m a. MonadWidget t m => Maybe String -> String -> Dynamic t (Map String String) -> m a -> m (El t, a)
651elDynAttrNS' :: forall t m a. MonadWidget t m => Maybe String -> String -> Dynamic t (Map String String) -> m a -> m (El t, a)
652elDynAttrNS' mns elementTag attrs = elWith' elementTag $
652elDynAttrNS' mns elementTag attrs = elWith' elementTag $
653 def & namespace .~ mns
653 def & namespace .~ mns
654− & attributes .~ attrs
654+ & elConfig_attributes .~ attrs
655
655
656{-# INLINABLE elDynAttr' #-}
656{-# INLINABLE elDynAttr' #-}
657elDynAttr' :: forall t m a. MonadWidget t m => String -> Dynamic t (Map String String) -> m a -> m (El t, a)
657elDynAttr' :: forall t m a. MonadWidget t m => String -> Dynamic t (Map String String) -> m a -> m (El t, a)
658−elDynAttr' elementTag attrs = elWith' elementTag $ def & attributes .~ attrs
658+elDynAttr' elementTag attrs = elWith' elementTag $ def & elConfig_attributes .~ attrs
659
659
660{-# INLINABLE elAttr #-}
660{-# INLINABLE elAttr #-}
661elAttr :: forall t m a. MonadWidget t m => String -> Map String String -> m a -> m a
661elAttr :: forall t m a. MonadWidget t m => String -> Map String String -> m a -> m a
@@ -671,7 +671,7 @@ elAttr' elementTag attrs = elWith' elementTag $ def & attributes .~ attrs
671
671
672{-# INLINABLE elDynAttr #-}
672{-# INLINABLE elDynAttr #-}
673elDynAttr :: forall t m a. MonadWidget t m => String -> Dynamic t (Map String String) -> m a -> m a
673elDynAttr :: forall t m a. MonadWidget t m => String -> Dynamic t (Map String String) -> m a -> m a
674−elDynAttr elementTag attrs = elWith elementTag $ def & attributes .~ attrs
674+elDynAttr elementTag attrs = elWith elementTag $ def & elConfig_attributes .~ attrs
675
675
676{-# INLINABLE el #-}
676{-# INLINABLE el #-}
677el :: forall t m a. MonadWidget t m => String -> m a -> m a
677el :: forall t m a. MonadWidget t m => String -> m a -> m a
@@ -713,10 +713,12 @@ data Link t
713 = Link { _link_clicked :: Event t ()
713 = Link { _link_clicked :: Event t ()
714 }
714 }
715
715
716−class HasAttributes s t a b | s -> a, t -> b, s b -> t, t a -> s where
716+class HasAttributes a where
717+ type Attrs a :: *
717− attributes :: Lens s t a b
718+ attributes :: Lens' a (Attrs a)
718
719
719−instance HasAttributes (ElConfig attrs) (ElConfig attrs') attrs attrs' where
720+instance HasAttributes (ElConfig attrs) where
721+ type Attrs (ElConfig attrs) = attrs
720 attributes = elConfig_attributes
722 attributes = elConfig_attributes
721
723
722class HasNamespace a where
724class HasNamespace a where
src/Reflex/Dom/Widget/Input.hs+9−5
@@ -1,4 +1,4 @@
1−{-# LANGUAGE ConstraintKinds, TypeFamilies, FlexibleContexts, DataKinds, GADTs, ScopedTypeVariables, FlexibleInstances, RecursiveDo, TemplateHaskell, MultiParamTypeClasses #-}
1+{-# LANGUAGE ConstraintKinds, TypeFamilies, FlexibleContexts, DataKinds, GADTs, ScopedTypeVariables, FlexibleInstances, RecursiveDo, TemplateHaskell #-}
2module Reflex.Dom.Widget.Input (module Reflex.Dom.Widget.Input, def, (&), (.~)) where
2module Reflex.Dom.Widget.Input (module Reflex.Dom.Widget.Input, def, (&), (.~)) where
3
3
4import Prelude
4import Prelude
@@ -222,16 +222,20 @@ liftM concat $ mapM makeLenses
222 , ''Checkbox
222 , ''Checkbox
223 ]
223 ]
224
224
225−instance HasAttributes (TextAreaConfig t) (TextAreaConfig t) (Dynamic t (Map String String)) (Dynamic t (Map String String)) where
225+instance HasAttributes (TextAreaConfig t) where
226+ type Attrs (TextAreaConfig t) = Dynamic t (Map String String)
226 attributes = textAreaConfig_attributes
227 attributes = textAreaConfig_attributes
227
228
228−instance HasAttributes (TextInputConfig t) (TextInputConfig t) (Dynamic t (Map String String)) (Dynamic t (Map String String)) where
229+instance HasAttributes (TextInputConfig t) where
230+ type Attrs (TextInputConfig t) = Dynamic t (Map String String)
229 attributes = textInputConfig_attributes
231 attributes = textInputConfig_attributes
230
232
231−instance HasAttributes (DropdownConfig t k) (DropdownConfig t k) (Dynamic t (Map String String)) (Dynamic t (Map String String)) where
233+instance HasAttributes (DropdownConfig t k) where
234+ type Attrs (DropdownConfig t k) = Dynamic t (Map String String)
232 attributes = dropdownConfig_attributes
235 attributes = dropdownConfig_attributes
233
236
234−instance HasAttributes (CheckboxConfig t) (CheckboxConfig t) (Dynamic t (Map String String)) (Dynamic t (Map String String)) where
237+instance HasAttributes (CheckboxConfig t) where
238+ type Attrs (CheckboxConfig t) = Dynamic t (Map String String)
235 attributes = checkboxConfig_attributes
239 attributes = checkboxConfig_attributes
236
240
237class HasSetValue a where
241class HasSetValue a where