X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FBit.hs;fp=src%2FBit.hs;h=1c7de7bf4169862cf791e8ebf6bd5e92751a4852;hb=64dfebebdecd1119ab8345a6de34597f6a878a98;hp=0000000000000000000000000000000000000000;hpb=49a0976cbc0f512442682e3095e1bcb657919da0;p=hath.git diff --git a/src/Bit.hs b/src/Bit.hs new file mode 100644 index 0000000..1c7de7b --- /dev/null +++ b/src/Bit.hs @@ -0,0 +1,15 @@ +module Bit where + +data Bit = Zero | One + deriving (Eq, Show) + +bit_to_int :: Bit -> Int +bit_to_int Zero = 0 +bit_to_int One = 1 + +-- If we are passed a '0' or '1', convert it appropriately. Otherwise, +-- default to Zero. +bit_from_char :: Char -> Bit +bit_from_char '0' = Zero +bit_from_char '1' = One +bit_from_char _ = Zero