[commit: ghc] ghc-8.0: Add Data.Functor.Classes instances for Proxy (trac issue #11756) (dc81cca)

git at git.haskell.org git at git.haskell.org
Tue Mar 29 17:38:24 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/dc81cca703559ffd4acb0a2f47c2f20956c22a3a/ghc

>---------------------------------------------------------------

commit dc81cca703559ffd4acb0a2f47c2f20956c22a3a
Author: Andrew Martin <amartin at layer3com.com>
Date:   Tue Mar 29 10:57:47 2016 +0200

    Add Data.Functor.Classes instances for Proxy (trac issue #11756)
    
    Test Plan: currently no test plan
    
    Reviewers: hvr, RyanGlScott, bgamari, austin
    
    Reviewed By: RyanGlScott, bgamari, austin
    
    Subscribers: thomie, RyanGlScott, andrewthad
    
    Differential Revision: https://phabricator.haskell.org/D2051
    
    GHC Trac Issues: #11756
    
    (cherry picked from commit 5097f3802124cfbe6810bff8110df91d4c52096b)


>---------------------------------------------------------------

dc81cca703559ffd4acb0a2f47c2f20956c22a3a
 libraries/base/Data/Functor/Classes.hs | 18 ++++++++++++++++++
 libraries/base/changelog.md            |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/libraries/base/Data/Functor/Classes.hs b/libraries/base/Data/Functor/Classes.hs
index 0ec6008..5f1b12c 100644
--- a/libraries/base/Data/Functor/Classes.hs
+++ b/libraries/base/Data/Functor/Classes.hs
@@ -62,6 +62,7 @@ module Data.Functor.Classes (
 
 import Control.Applicative (Const(Const))
 import Data.Functor.Identity (Identity(Identity))
+import Data.Proxy (Proxy(Proxy))
 import Data.Monoid (mappend)
 import Text.Show (showListWith)
 
@@ -354,6 +355,23 @@ instance (Read a) => Read1 (Const a) where
 instance (Show a) => Show1 (Const a) where
     liftShowsPrec = liftShowsPrec2 showsPrec showList
 
+-- | @since 4.9.0.0
+instance Eq1 Proxy where
+  liftEq _ _ _ = True
+
+-- | @since 4.9.0.0
+instance Ord1 Proxy where
+  liftCompare _ _ _ = EQ
+
+-- | @since 4.9.0.0
+instance Show1 Proxy where
+  liftShowsPrec _ _ _ _ = showString "Proxy"
+
+-- | @since 4.9.0.0
+instance Read1 Proxy where
+  liftReadsPrec _ _ d =
+    readParen (d > 10) (\r -> [(Proxy, s) | ("Proxy",s) <- lex r ])
+
 -- Building blocks
 
 -- | @'readsData' p d@ is a parser for datatypes where each alternative
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 92451b9..cb3eced 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -78,6 +78,9 @@
     `Data.Functor.Product`, and `Data.Functor.Sum` (previously provided by
     `transformers` package). (#11135)
 
+  * New instances for `Proxy`: `Eq1`, `Ord1`, `Show1`, `Read1`. All
+    of the classes are from `Data.Functor.Classes` (#11756).
+
   * New module `Control.Monad.Fail` providing new `MonadFail(fail)`
     class (#10751)
 



More information about the ghc-commits mailing list