on develop help sign in
Revert "Make HasAttributes more polymorphic"

This reverts commit c24dbf065cfd18de88fd0131649916086ea430bd.

commit204e4ec954fc3add3154e2cf3f2660c5ffd3fcac authorRyan Trinkle <ryan.trinkle@gmail.com> dateFri 18 Sep 2015, 16:41 (11 years ago) parentfbb6e19
2 files changed+18−12
src/Reflex/Dom/Widget/Basic.hs+9−7 src/Reflex/Dom/Widget/Input.hs+9−5
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 #-}
22
33module Reflex.Dom.Widget.Basic where
44
@@ -651,11 +651,11 @@ emptyElWith' elementTag cfg = do
651651elDynAttrNS' :: forall t m a. MonadWidget t m => Maybe String -> String -> Dynamic t (Map String String) -> m a -> m (El t, a)
652652elDynAttrNS' mns elementTag attrs = elWith' elementTag $
653653 def & namespace .~ mns
654− & attributes .~ attrs
654+ & elConfig_attributes .~ attrs
655655
656656{-# INLINABLE elDynAttr' #-}
657657elDynAttr' :: 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
659659
660660{-# INLINABLE elAttr #-}
661661elAttr :: 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
671671
672672{-# INLINABLE elDynAttr #-}
673673elDynAttr :: 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
675675
676676{-# INLINABLE el #-}
677677el :: forall t m a. MonadWidget t m => String -> m a -> m a
@@ -713,10 +713,12 @@ data Link t
713713 = Link { _link_clicked :: Event t ()
714714 }
715715
716−class HasAttributes s t a b | s -> a, t -> b, s b -> t, t a -> s where
717− attributes :: Lens s t a b
716+class HasAttributes a where
717+ type Attrs a :: *
718+ attributes :: Lens' a (Attrs a)
718719
719−instance HasAttributes (ElConfig attrs) (ElConfig attrs') attrs attrs' where
720+instance HasAttributes (ElConfig attrs) where
721+ type Attrs (ElConfig attrs) = attrs
720722 attributes = elConfig_attributes
721723
722724class 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 #-}
22module Reflex.Dom.Widget.Input (module Reflex.Dom.Widget.Input, def, (&), (.~)) where
33
44import Prelude
@@ -222,16 +222,20 @@ liftM concat $ mapM makeLenses
222222 , ''Checkbox
223223 ]
224224
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)
226227 attributes = textAreaConfig_attributes
227228
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)
229231 attributes = textInputConfig_attributes
230232
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)
232235 attributes = dropdownConfig_attributes
233236
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)
235239 attributes = checkboxConfig_attributes
236240
237241class HasSetValue a where