Yes, I believe that's right. As far as I can figure out, these classes really *are* problematic, in that if we allowed GeneralizedNewtypeDeriving for them, there would be a way to subvert the type system. To make these derivable, we would need to be able to restrict various type parameters from taking on values that take a nominal argument. Without the ability to restrict the values in this way, there could be trouble.
Richard On Dec 14, 2013, at 4:52 PM, Ben Gamari wrote: > Edward Kmett <ekm...@gmail.com> writes: > >> If this forced me to write those instances by hand, I could accept >> that as a tax for correctness. It means you can't GND any of the >> HasFoo dictionaries that lens builds, but meh. >> > Am I correct in assuming that Bind, R1, R2, R3, and R4 are the > problematic instances in linear? With recent GHC I get the errors below. > > Cheers, > > - Ben > > > src/Linear/Affine.hs:112:34: > Could not coerce from ‛f (f a)’ to ‛f (Point f a)’ > because ‛f (f a)’ and ‛f (Point f a)’ are different types. > arising from the coercion of the method ‛join’ from type > ‛forall a. f (f a) -> f a’ to type > ‛forall a. Point f (Point f a) -> Point f a’ > Possible fix: > use a standalone 'deriving instance' declaration, > so you can specify the instance context yourself > When deriving the instance for (Bind (Point f)) > > src/Linear/Affine.hs:112:58: > Could not coerce from ‛g (f x)’ to ‛g (Point f x)’ > because ‛g (f x)’ and ‛g (Point f x)’ are different types. > arising from the coercion of the method ‛core’ from type > ‛forall a. > ((forall (g :: * -> *) x. > Functor g => > (x -> g x) -> f x -> g (f x)) > -> a) > -> f a’ > to type > ‛forall a. > ((forall (g :: * -> *) x. > Functor g => > (x -> g x) -> Point f x -> g (Point f x)) > -> a) > -> Point f a’ > Possible fix: > use a standalone 'deriving instance' declaration, > so you can specify the instance context yourself > When deriving the instance for (Core (Point f)) > > src/Linear/Affine.hs:112:64: > Could not coerce from ‛f1 (f a)’ to ‛f1 (Point f a)’ > because ‛f1 (f a)’ and ‛f1 (Point f a)’ are different types. > arising from the coercion of the method ‛_x’ from type > ‛forall a (f :: * -> *). Functor f => (a -> f a) -> f a > -> f (f a)’ > to type > ‛forall a (f :: * -> *). > Functor f => > (a -> f a) -> Point f a -> f (Point f a)’ > Possible fix: > use a standalone 'deriving instance' declaration, > so you can specify the instance context yourself > When deriving the instance for (R1 (Point f)) > > src/Linear/Affine.hs:112:68: > Could not coerce from ‛f1 (f a)’ to ‛f1 (Point f a)’ > because ‛f1 (f a)’ and ‛f1 (Point f a)’ are different types. > arising from the coercion of the method ‛_xy’ from type > ‛forall a (f :: * -> *). > Functor f => > (V2 a -> f (V2 a)) -> f a -> f (f a)’ > to type > ‛forall a (f :: * -> *). > Functor f => > (V2 a -> f (V2 a)) -> Point f a -> f (Point f a)’ > Possible fix: > use a standalone 'deriving instance' declaration, > so you can specify the instance context yourself > When deriving the instance for (R2 (Point f)) > > src/Linear/Affine.hs:112:68: > Could not coerce from ‛f1 (f a)’ to ‛f1 (Point f a)’ > because ‛f1 (f a)’ and ‛f1 (Point f a)’ are different types. > arising from the coercion of the method ‛_y’ from type > ‛forall a (f :: * -> *). Functor f => (a -> f a) -> f a > -> f (f a)’ > to type > ‛forall a (f :: * -> *). > Functor f => > (a -> f a) -> Point f a -> f (Point f a)’ > Possible fix: > use a standalone 'deriving instance' declaration, > so you can specify the instance context yourself > When deriving the instance for (R2 (Point f)) > > src/Linear/Affine.hs:112:72: > Could not coerce from ‛f1 (f a)’ to ‛f1 (Point f a)’ > because ‛f1 (f a)’ and ‛f1 (Point f a)’ are different types. > arising from the coercion of the method ‛_xyz’ from type > ‛forall a (f :: * -> *). > Functor f => > (V3 a -> f (V3 a)) -> f a -> f (f a)’ > to type > ‛forall a (f :: * -> *). > Functor f => > (V3 a -> f (V3 a)) -> Point f a -> f (Point f a)’ > Possible fix: > use a standalone 'deriving instance' declaration, > so you can specify the instance context yourself > When deriving the instance for (R3 (Point f)) > > src/Linear/Affine.hs:112:72: > Could not coerce from ‛f1 (f a)’ to ‛f1 (Point f a)’ > because ‛f1 (f a)’ and ‛f1 (Point f a)’ are different types. > arising from the coercion of the method ‛_z’ from type > ‛forall a (f :: * -> *). Functor f => (a -> f a) -> f a > -> f (f a)’ > to type > ‛forall a (f :: * -> *). > Functor f => > (a -> f a) -> Point f a -> f (Point f a)’ > Possible fix: > use a standalone 'deriving instance' declaration, > so you can specify the instance context yourself > When deriving the instance for (R3 (Point f)) > > src/Linear/Affine.hs:112:76: > Could not coerce from ‛f1 (f a)’ to ‛f1 (Point f a)’ > because ‛f1 (f a)’ and ‛f1 (Point f a)’ are different types. > arising from the coercion of the method ‛_xyzw’ from type > ‛forall a (f :: * -> *). > Functor f => > (V4 a -> f (V4 a)) -> f a -> f (f a)’ > to type > ‛forall a (f :: * -> *). > Functor f => > (V4 a -> f (V4 a)) -> Point f a -> f (Point f a)’ > Possible fix: > use a standalone 'deriving instance' declaration, > so you can specify the instance context yourself > When deriving the instance for (R4 (Point f)) > > src/Linear/Affine.hs:112:76: > Could not coerce from ‛f1 (f a)’ to ‛f1 (Point f a)’ > because ‛f1 (f a)’ and ‛f1 (Point f a)’ are different types. > arising from the coercion of the method ‛_w’ from type > ‛forall a (f :: * -> *). Functor f => (a -> f a) -> f a > -> f (f a)’ > to type > ‛forall a (f :: * -> *). > Functor f => > (a -> f a) -> Point f a -> f (Point f a)’ > Possible fix: > use a standalone 'deriving instance' declaration, > so you can specify the instance context yourself > When deriving the instance for (R4 (Point f)) _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs