summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_compile/T9155.hs
blob: 6fac0bcee6c24924ddd6aab4a122ee09d49e9684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE ScopedTypeVariables #-}
module M () where

import Data.Bits ((.&.))

bitsSet :: Int -> Int -> Bool
bitsSet mask i
  = (i .&. mask == mask)

class Eq b => BitMask b where
  assocBitMask :: [(b,Int)]

  fromBitMask  :: Int -> b
  fromBitMask i
    = walk assocBitMask
    where
      walk []         = error "Graphics.UI.WX.Types.fromBitMask: empty list"
      walk [(x,0)]    = x
      walk ((x,m):xs) | bitsSet m i = x
                      | otherwise   = walk xs

data Align   = AlignLeft
             | AlignCentre
             deriving Eq

instance BitMask Align where
  assocBitMask
    = [(AlignCentre,512)
      ,(AlignLeft,  256)
      ]