Skip to content

Commit

Permalink
Add class constraints for ghc-7.6.1 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmikus committed Nov 6, 2012
1 parent 818bbce commit af13e6e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/C2HS.hs
Expand Up @@ -161,13 +161,13 @@ nothingIfNull = nothingIf (== nullPtr)
-- Given a list of enumeration values that represent bit masks, combine these
-- masks using bitwise disjunction.
--
combineBitMasks :: (Enum a, Bits b) => [a] -> b
combineBitMasks :: (Enum a, Bits b, Num b) => [a] -> b
combineBitMasks = foldl (.|.) 0 . map (fromIntegral . fromEnum)

-- Tests whether the given bit mask is contained in the given bit pattern
-- (i.e., all bits set in the mask are also set in the pattern).
--
containsBitMask :: (Bits a, Enum b) => a -> b -> Bool
containsBitMask :: (Bits a, Num a, Enum b) => a -> b -> Bool
bits `containsBitMask` bm = let bm' = fromIntegral . fromEnum $ bm
in
bm' .&. bits == bm'
Expand All @@ -178,7 +178,7 @@ bits `containsBitMask` bm = let bm' = fromIntegral . fromEnum $ bm
-- combined yield the bit pattern, instead all contained bit masks are
-- produced.
--
extractBitMasks :: (Bits a, Enum b, Bounded b) => a -> [b]
extractBitMasks :: (Bits a, Num a, Enum b, Bounded b) => a -> [b]
extractBitMasks bits =
[bm | bm <- [minBound..maxBound], bits `containsBitMask` bm]

Expand Down

0 comments on commit af13e6e

Please sign in to comment.