1. paradoxiology
  2. BounceWire

Commits

paradoxiology  committed 1d3899f

Tidy up

  • Participants
  • Parent commits d955ab5
  • Branches default

Comments (0)

Files changed (2)

File src/Main.hs

View file
 data Ball = Ball !Vec2 !Color deriving (Show)
 
 initWorld :: WireWorld
-initWorld = WireWorld animateBalls [] [] (mkStdGen 8552) (WorldEnv 600 480)
+initWorld = WireWorld
+              animateBalls
+              []
+              []
+              (mkStdGen 8552)
+              (WorldEnv 600 480)
 
 handleEvents :: Event -> WireWorld -> WireWorld
 handleEvents (EventResize (newWidth, newHeight)) oldWorld = 
 isKeyActive keyState k  = any checkKeyActive
   where 
     checkKeyActive (EventKey (SpecialKey sk) state _ _) = state == keyState && sk == k
-    checkKeyActive _                                   = False
+    checkKeyActive _                                    = False
 
 isKeyDown :: SpecialKey -> [Event] -> Bool
 isKeyDown = isKeyActive Down

File src/WireUtils.hs

View file
         let dt  =  realToFrac (dtime ds)
         -- Use res as opposed to explicitly destruct(pattern match)
         -- the tuple (x1, 0) to avoid evaluation of the tuple in the do notation
-        -- (Because of the implicitly threaded ordering)
+        -- (Because of the implicitly sequenced ordering)
         res <- correct (x0 &+ dt *& dx)
         return $ x0 `seq` (Right (x0, snd res), go (fst res)) 
 
 mergeWires :: (Monad m, Monoid s) => [Wire s e m a b] -> Wire s e m (a, [Wire s e m a b]) [b]
-mergeWires wires = mkGen $ \ds (a, newWires) -> do
-  stepped <- mapM (\w -> stepWire w ds (Right a)) (newWires ++ wires)
+mergeWires wires = mkGen $ \ds (x, newWires) -> do
+  stepped <- mapM (\w -> stepWire w ds (Right x)) (newWires ++ wires)
   -- Filter out inhibited wires, and extract the outputs and future wires out separately
   let (o', wires') = unzip [(o, w') | (Right o, w') <- stepped]
   return (Right o', mergeWires wires')
 
 -- Produce one value now then inhibit
 oneShot :: (Monoid e) => Wire s e m a a
-oneShot = mkPureN $ \a -> (Right a, inhibit mempty)
-            
+oneShot = mkPureN $ \x -> (Right x, inhibit mempty)
+
 -- Produce one value for one instance from now periodically
 periodicShots :: (HasTime t s, Monoid e) => t -> Wire s e m a a
 periodicShots int | int <= 0 =  error "periodicShots: Non-positive interval"
             in if t <= 0
                  then (Right x, go (mod' t int))
                  else (Left mempty, go t)
+