## Haskell Yampa

In my last post I mentioned that I had been looking at some Haskell libraries. Yampa has been my main interest. Using Yampa it is possible to define signals and signal processing functions. Signals are time varying functions and, for example, game ai behavior can be expressed using signals. I started out much simpler and here is my initial test:

import FRP.Yampa

add10 :: SF Int Int

add10 = arr $ (\x -> x+10)gt20 :: SF Int Bool

gt20 = arr $ (\x -> x > 20)composite :: SF Int Bool

composite = add10 >>> gt20— arrow notation, http://www.haskell.org/ghc/docs/7.2.2/html/users_guide/arrow-notation.html

— requires -XArrows flag, GHC

add10ext :: SF Int Int

add10ext = proc x -> returnA -< x + 10compositeExt :: SF Int Bool

compositeExt = proc x -> do

y <- identity -< x + 10

returnA -< y > 20

As suggested here primitive signal functions can be tested using the embed function. For example:

putStrLn $ show $ embed compositeExt (5, [(1, Nothing), (2, Just 17), (3, Nothing)])

— [False,False,True,True]

Its such as you read my mind! You appear to know so much approximately this, like you wrote the book

in it or something. I feel that you could do with some % to power the message home

a bit, but instead of that, this is great blog. An excellent read.

I’ll certainly be back.

Your words are pure inspiration for me. Thanks!