Also, one more thing - if someone could write some comments to go along with the source code that explain what it is doing, that would be really helpful. I can see the general structure, but I don't know the ins and outs of Haskell. If someone could augment the example with comments explaining what the functions do that would be great!

data Door = Open | Closed deriving Show

 

toggle Open   = Closed
toggle Closed = Open

 

pass k = zipWith ($) (cycle $ replicate k id ++ [toggle])

 

run n = foldl (flip pass) (replicate n Closed) [0..n]

Do I need to add run 100 to the end of the example for it to actually do something?