]> gitweb.michael.orlitzky.com - hath.git/blob - src/Bit.hs
c01ae94b5563df50707a23c3e5dfc19b6257ebb6
[hath.git] / src / Bit.hs
1 -- | The Bit module contains the Bit data type, which is essentially a
2 -- renamed Boolean, and some convenience functions.
3 module Bit (
4 Bit(..)
5 )
6 where
7
8 import Test.QuickCheck (
9 Arbitrary,
10 arbitrary,
11 elements
12 )
13
14
15 data Bit = Zero | One
16 deriving (Enum, Eq)
17
18 instance Show Bit where
19 show Zero = "0"
20 show One = "1"
21
22
23 instance Arbitrary Bit where
24 arbitrary = elements [ Zero, One ]
25
26
27 instance Ord Bit where
28 Zero <= Zero = True
29 Zero <= One = True
30 One <= Zero = False
31 One <= One = True
32
33 instance Bounded Bit where
34 minBound = Zero
35 maxBound = One