PageRenderTime 17ms CodeModel.GetById 3ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/Psp/Specifications.hs

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