Ticket #7135: 0001-Data.Bits-Use-XDefaultSignatures-to-have-default-ins.patch

File 0001-Data.Bits-Use-XDefaultSignatures-to-have-default-ins.patch, 1.2 KB (added by joeyadams, 3 years ago)

Data.Bits: Use -XDefaultSignatures to have default instances for bit, testBit, and popCount

  • Data/Bits.hs

    From 40d6b2c7a57c4ee0af83f6d2e772e9baa6f55189 Mon Sep 17 00:00:00 2001
    From: Joey Adams <[email protected]>
    Date: Sun, 12 Aug 2012 21:15:16 -0400
    Subject: [PATCH] Data.Bits: Use -XDefaultSignatures to have default instances for bit, testBit, and popCount
    
    ---
     Data/Bits.hs |   15 ++++++++++++++-
     1 files changed, 14 insertions(+), 1 deletions(-)
    
    diff --git a/Data/Bits.hs b/Data/Bits.hs
    index 14a6357..bd171f2 100644
    a b  
    1818-- "Data.Int" and "Data.Word" modules. 
    1919-- 
    2020----------------------------------------------------------------------------- 
    21  
     21#ifdef __GLASGOW_HASKELL__ 
     22{-# LANGUAGE DefaultSignatures #-} 
     23#endif 
    2224module Data.Bits (  
    2325  Bits( 
    2426    (.&.), (.|.), xor, -- :: a -> a -> a 
    class Eq a => Bits a where 
    238240        known as the population count or the Hamming weight. -} 
    239241    popCount          :: a -> Int 
    240242 
     243#ifdef __GLASGOW_HASKELL__ 
     244    default bit :: Num a => Int -> a 
     245    bit = bitDefault 
     246 
     247    default testBit :: Num a => a -> Int -> Bool 
     248    testBit = testBitDefault 
     249 
     250    default popCount :: Num a => a -> Int 
     251    popCount = popCountDefault 
     252#endif 
     253 
    241254-- | Default implementation for 'bit'. 
    242255-- 
    243256-- Note that: @bitDefault i = 1 `shiftL` i@