]> gitweb.michael.orlitzky.com - hath.git/blob - src/Bit.hs
Added three new modules which are currently independent of the rest of the code:...
[hath.git] / src / Bit.hs
1 module Bit where
2
3 data Bit = Zero | One
4 deriving (Eq, Show)
5
6 bit_to_int :: Bit -> Int
7 bit_to_int Zero = 0
8 bit_to_int One = 1
9
10 -- If we are passed a '0' or '1', convert it appropriately. Otherwise,
11 -- default to Zero.
12 bit_from_char :: Char -> Bit
13 bit_from_char '0' = Zero
14 bit_from_char '1' = One
15 bit_from_char _ = Zero