]> gitweb.michael.orlitzky.com - hath.git/blob - src/Bit.hs
Add some additional GHC warnings to the makefile.
[hath.git] / src / Bit.hs
1 module Bit where
2
3 data Bit = None | Zero | One
4 deriving (Eq)
5
6 instance Show Bit where
7 show None = "None"
8 show Zero = "0"
9 show One = "1"
10
11
12 bit_to_int :: Bit -> Int
13 bit_to_int None = -1
14 bit_to_int Zero = 0
15 bit_to_int One = 1
16
17 -- If we are passed a '0' or '1', convert it appropriately. Otherwise,
18 -- default to None.
19 bit_from_char :: Char -> Bit
20 bit_from_char '0' = Zero
21 bit_from_char '1' = One
22 bit_from_char _ = None