on develop help sign in
Make the Functor1Constraint family sensible

The form of the constraint should only depend on the functor, and never on the arguments. This means that the constraint may well need to be expressed using an auxiliary class, but everything should make more sense.

commitcbf2fb08c32b1e588d72a2a9e85e78f794b8487a authorDavid Feuer <David.Feuer@gmail.com> dateWed 7 Sep 2016, 20:55 (10 years ago) parentd82b04e
1 file changed+13−7
src/Reflex/Dom/Builder/Class.hs+13−7
src/Reflex/Dom/Builder/Class.hs+13−7
@@ -462,14 +462,20 @@ instance (DomBuilder t m, Monoid w, MonadHold t m, MonadFix m) => DomBuilder t (
462462
463463-- * Convenience functions
464464
465+class Unconstrained g h
466+instance Unconstrained g h
467+
468+class DomBuilderSpace a ~ DomBuilderSpace b => SameDomBuilderSpace a b
469+instance DomBuilderSpace a ~ DomBuilderSpace b => SameDomBuilderSpace a b
470+
465471--TODO: Move/replace
466472class Functor1 (f :: (k -> *) -> *) where
467− type Functor1Constraint f (a :: k -> *) (b :: k -> *) :: Constraint
468− type Functor1Constraint f a b = ()
473+ type Functor1Constraint f :: (k -> *) -> (k -> *) -> Constraint
474+ type Functor1Constraint f = Unconstrained
469475 fmap1 :: Functor1Constraint f a b => (forall x. a x -> b x) -> f a -> f b
470476
471477instance Functor1 (ElementConfig er t) where
472− type Functor1Constraint (ElementConfig er t) a b = DomBuilderSpace a ~ DomBuilderSpace b
478+ type Functor1Constraint (ElementConfig er t) = SameDomBuilderSpace
473479 {-# INLINABLE fmap1 #-}
474480 fmap1 _ cfg = cfg
475481 { _elementConfig_eventSpec = _elementConfig_eventSpec cfg
@@ -482,19 +488,19 @@ instance Reflex t => Functor1 (PlaceholderConfig above t) where
482488 }
483489
484490instance Functor1 (InputElementConfig er t) where
485− type Functor1Constraint (InputElementConfig er t) a b = Functor1Constraint (ElementConfig er t) a b
491+ type Functor1Constraint (InputElementConfig er t) = Functor1Constraint (ElementConfig er t)
486492 fmap1 f cfg = cfg & inputElementConfig_elementConfig %~ fmap1 f
487493
488494instance Functor1 (TextAreaElementConfig er t) where
489− type Functor1Constraint (TextAreaElementConfig er t) a b = Functor1Constraint (ElementConfig er t) a b
495+ type Functor1Constraint (TextAreaElementConfig er t) = Functor1Constraint (ElementConfig er t)
490496 fmap1 f cfg = cfg & textAreaElementConfig_elementConfig %~ fmap1 f
491497
492498instance Functor1 (SelectElementConfig er t) where
493− type Functor1Constraint (SelectElementConfig er t) a b = Functor1Constraint (ElementConfig er t) a b
499+ type Functor1Constraint (SelectElementConfig er t) = Functor1Constraint (ElementConfig er t)
494500 fmap1 f cfg = cfg & selectElementConfig_elementConfig %~ fmap1 f
495501
496502instance Functor1 (RawElementConfig er t) where
497− type Functor1Constraint (RawElementConfig er t) a b = DomBuilderSpace a ~ DomBuilderSpace b
503+ type Functor1Constraint (RawElementConfig er t) = SameDomBuilderSpace
498504 {-# INLINABLE fmap1 #-}
499505 fmap1 _ cfg = cfg
500506 { _rawElementConfig_eventSpec = _rawElementConfig_eventSpec cfg