/Psp/Specifications.hs

http://hdbc.googlecode.com/ · Haskell · 35 lines · 27 code · 8 blank · 0 comment · 0 complexity · f1288b4f9833dab06538b83fc773799d MD5 · raw file

  1. module Specifications where
  2. import Structures
  3. import Data.Array
  4. controlStateTable :: Array (Control, Int) (Sensitive, Display)
  5. controlStateTable = let (states, cntrls, stDetails) = controlStateSpec
  6. sts = map num states
  7. controlStateTuples = [(c,s) | c <- cntrls, s <- sts]
  8. in
  9. array ((head cntrls, head sts), (last cntrls, last sts)) (zip controlStateTuples stDetails)
  10. data Sensitive = S | NS deriving (Show, Eq)
  11. data Display = D String | Any deriving (Show, Eq)
  12. controlStateSpec = [ProjectInactive, ProjectActive Waiting, ProjectActive Paused, ProjectActive Recording] `hh` (
  13. (OpenProjectItem +>> [(S, Any) , (S, Any) , (NS, Any) , (NS, Any)]) +&&
  14. (QuitProjectItem +>> [(S, Any) , (S, Any) , (NS, Any) , (NS, Any)]) +&&
  15. (StageComboBox +>> [(NS, Any) , (S, Any) , (NS, Any) , (NS, Any)]) +&&
  16. (VariablesEntryBox +>> [(NS, D "") , (S, D "") , (NS, Any) , (NS, Any)]) +&&
  17. (TypeComboBox +>> [(NS, Any) , (NS, Any) , (NS, Any) , (S, Any)]) +&&
  18. (DescriptionEntryBox +>> [(NS, Any) , (NS, Any) , (NS, Any) , (S, D "")]) +&&
  19. (RecordButton +>> [(NS, Any) , (S, D "Record") , (NS, D "Stop") , (S, D "Stop")]) +&&
  20. (PauseButton +>> [(NS, Any) , (NS, D "Pause") , (S, D "Continue") , (S, D "Pause")]) +&&
  21. (AddButton +>> [(NS, Any) , (NS, Any) , (NS, Any) , (S, D "")]))
  22. (+>>) :: Control -> [(Sensitive, Display)] -> ([Control], [(Sensitive, Display)])
  23. c +>> ls = ([c], ls)
  24. (+&&) :: ([a], [b]) -> ([a], [b]) -> ([a], [b])
  25. (a, b) +&& (c, d) = (a ++ c, b ++ d)
  26. hh :: a -> (b, c) -> (a, b, c)
  27. hh a (b, c) = (a, b, c)