[Haskell-beginners] In Search Of a clue... (Defining and making use of a type)

Thomas haskell at phirho.com
Mon Dec 12 23:22:32 CET 2011


Hi Allen,

 > Here's what I'm doing so far,
 >
 > ----------------
 >
 > data ScrUple = ScrUple { xineramascreen :: Integer
 > , workspace :: String
 > } deriving (Show)
 >
 > data ScrConfig = ScrConfig [ ScrUple ] deriving (Show)
 >
 >
 >
 > s1 = ScrUple 0 "mail"
 > s2 = ScrUple 1 "web"
 >
 >
 > ScrConfig sc1 =ScrConfig( [s2 s1] ) ;

   sc1 = ScrConfig [s2, s1]

 > main = putStrLn $ show sc1[1]

   main = putStrLn $ show sc1

To print just parts of a ScrConfig you'll probably want a helper 
function. Maybe something like:

   scPrint (ScrConfig sus) nth = show (sus !! nth)

(it will make problems on out-of-bounds-indexes!)

HTH,
Thomas







More information about the Beginners mailing list