summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Setup.hs2
-rw-r--r--axis-of-eval.cabal21
-rw-r--r--axis.hs36
3 files changed, 59 insertions, 0 deletions
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
index 0000000..9a994af
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
1import Distribution.Simple
2main = defaultMain
diff --git a/axis-of-eval.cabal b/axis-of-eval.cabal
new file mode 100644
index 0000000..2942f16
--- /dev/null
+++ b/axis-of-eval.cabal
@@ -0,0 +1,21 @@
1-- Initial axis-of-eval.cabal generated by cabal init. For further
2-- documentation, see http://haskell.org/cabal/users-guide/
3
4name: axis-of-eval
5version: 0.0.0.1
6-- synopsis:
7-- description:
8homepage: axis.childrenofmay.org
9license: AllRightsReserved
10license-file: LICENSE
11author: Andrew Cady
12maintainer: d@childrenofmay.org
13-- copyright:
14category: Sound
15build-type: Simple
16cabal-version: >=1.8
17
18executable axis-of-eval
19 -- main-is:
20 -- other-modules:
21 build-depends: base ==4.5.* \ No newline at end of file
diff --git a/axis.hs b/axis.hs
new file mode 100644
index 0000000..b59a6f6
--- /dev/null
+++ b/axis.hs
@@ -0,0 +1,36 @@
1import FRP.Netwire hiding (when)
2import Prelude hiding ((.), id)
3import Data.Time.Clock
4import Control.Wire hiding (when)
5import Control.Wire.Session
6import Control.Monad
7import qualified Graphics.UI.SDL as SDL
8
9netwireIsCool :: (Monad m) => Wire (Timed NominalDiffTime ()) () m a String
10netwireIsCool =
11 for 2.5 . pure "Once upon a time..." -->
12 for 3 . pure "... games were completely imperative..." -->
13 for 2 . pure "... but then..." -->
14 for 10 . (pure "Netwire 5! " <> anim) -->
15 netwireIsCool
16
17 where
18 anim =
19 holdFor 0.5 . periodic 1 . pure "Hoo..." <|>
20 pure "...ray!"
21
22--main :: IO ()
23--main = testWire clockSession_ netwireIsCool
24
25main = SDL.withInit [SDL.InitVideo, SDL.InitTimer, SDL.InitJoystick] $ do
26 loop clockSession_ netwireIsCool ""
27 where
28 loop s w x = do
29 (ds, s') <- stepSession s
30 (ex, w') <- stepWire w ds (Right x)
31 let x' = either (const "") id ex
32 Control.Monad.when (x /= x' && x /= "") $ putStrLn x
33 let framerate = 30
34 let delay = 1000 `div` framerate - 1000 * (floor $ dtime ds)
35 SDL.delay (delay)
36 loop s' w' x'