[commit: base] ghc-generics: Add instances for basic types of the new generic deriving mechanism. (eb87007)
José Pedro Magalhães
jpm at cs.uu.nl
Fri Apr 29 16:19:07 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : ghc-generics
http://hackage.haskell.org/trac/ghc/changeset/eb87007595377966ab5544f6e204e58a49deb3a9
>---------------------------------------------------------------
commit eb87007595377966ab5544f6e204e58a49deb3a9
Author: Jose Pedro Magalhaes <jpm at cs.uu.nl>
Date: Fri Apr 29 08:46:08 2011 +0200
Add instances for basic types of the new generic deriving mechanism.
>---------------------------------------------------------------
GHC/Int.hs | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/GHC/Int.hs b/GHC/Int.hs
index 05d10c5..bafa7f0 100644
--- a/GHC/Int.hs
+++ b/GHC/Int.hs
@@ -1,4 +1,5 @@
-{-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, MagicHash #-}
+{-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, MagicHash,
+ StandaloneDeriving #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
-- |
@@ -41,6 +42,8 @@ import GHC.Err
import GHC.Word hiding (uncheckedShiftL64#, uncheckedShiftRL64#)
import GHC.Show
import GHC.Float () -- for RealFrac methods
+-- For defining instances for the new generic deriving mechanism
+import GHC.Generics (Arity(..), Associativity(..), Fixity(..))
------------------------------------------------------------------------
-- type Int8
@@ -907,3 +910,26 @@ instance Ix Int64 where
range (m,n) = [m..n]
unsafeIndex (m,_) i = fromIntegral i - fromIntegral m
inRange (m,n) i = m <= i && i <= n
+
+------------------------------------------------------------------------
+-- Generic deriving
+------------------------------------------------------------------------
+
+-- We need instances for some basic datatypes, but some of those use Int,
+-- so we have to put the instances here
+
+deriving instance Eq Arity
+deriving instance Eq Associativity
+deriving instance Eq Fixity
+
+deriving instance Ord Arity
+deriving instance Ord Associativity
+deriving instance Ord Fixity
+
+deriving instance Read Arity
+deriving instance Read Associativity
+deriving instance Read Fixity
+
+deriving instance Show Arity
+deriving instance Show Associativity
+deriving instance Show Fixity
More information about the Cvs-libraries
mailing list