summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorRyanGlScott <ryan.gl.scott@gmail.com>2016-04-11 02:53:23 +0200
committerBen Gamari <ben@smart-cactus.org>2016-04-11 02:53:24 +0200
commitaadde2b90817c577336da0d4a10ea47551d60c7e (patch)
tree09840461f8c98180b486b34f68d8c97a210113bb /libraries
parent8b57cac5974c9fffccbcae3104b5b5d18760749e (diff)
downloadhaskell-aadde2b90817c577336da0d4a10ea47551d60c7e.tar.gz
Deriving Functor-like classes should unify kind variables
While the deriving machinery always unifies the kind of the typeclass argument with the kind of the datatype, this proves not to be sufficient to produce well kinded instances for some poly-kinded datatypes. For example: ``` newtype Compose (f :: k2 -> *) (g :: k1 -> k2) (a :: k1) = Compose (f (g a)) deriving Functor ``` would fail because only `k1` would get unified with `*`, causing the following ill kinded instance to be generated: ``` instance (Functor (f :: k2 -> *), Functor (g :: * -> k2)) => Functor (Compose f g) where ... ``` To prevent this, we need to take the subtypes and unify their kinds with `* -> *`. Fixes #10524 for good. Test Plan: ./validate Reviewers: simonpj, hvr, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2097 GHC Trac Issues: #10524, #10561
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/Data/Functor/Compose.hs7
1 files changed, 1 insertions, 6 deletions
diff --git a/libraries/base/Data/Functor/Compose.hs b/libraries/base/Data/Functor/Compose.hs
index 230f4e77de..d548836820 100644
--- a/libraries/base/Data/Functor/Compose.hs
+++ b/libraries/base/Data/Functor/Compose.hs
@@ -2,7 +2,6 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE Safe #-}
-{-# LANGUAGE StandaloneDeriving #-}
-----------------------------------------------------------------------------
-- |
-- Module : Data.Functor.Compose
@@ -36,11 +35,7 @@ infixr 9 `Compose`
-- The composition of applicative functors is always applicative,
-- but the composition of monads is not always a monad.
newtype Compose f g a = Compose { getCompose :: f (g a) }
- deriving (Data, Generic)
-
--- We must use standalone deriving here due to a bad interaction between
--- PolyKinds and GHC generics
-deriving instance Functor f => Generic1 (Compose f g)
+ deriving (Data, Generic, Generic1)
-- Instances of lifted Prelude classes