You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CircuitBase.hs 688B

1234567891011121314151617181920212223
  1. module CircuitBase (Circuit(..), Chamber(..), Car(..), server_input, circ_from_perm) where
  2. import Encoding
  3. data Circuit = Circuit { outPin :: Int, inPins :: [Int] } deriving (Eq, Show)
  4. circ_from_perm (x:xs) = if (odd $ length xs) then error "Wrong pin count" else Circuit x xs
  5. data Chamber = Chamber { upperPipe :: [Int], mainChamber :: Bool, lowerPipe :: [Int] }
  6. data Car = Car { chambers :: [Chamber] }
  7. instance Encode Chamber where
  8. sdecode = do
  9. (a, b, c) <- sdecode
  10. return $ Chamber a (not b) c
  11. sencode (Chamber a b c) = sencode (a, not b, c)
  12. instance Encode Car where
  13. sdecode = sdecode >>= (return . Car)
  14. sencode (Car a) = sencode a
  15. server_input = "01202101210201202"