]> gitweb.michael.orlitzky.com - hath.git/blob - src/Bit.hs
1c7de7bf4169862cf791e8ebf6bd5e92751a4852
[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