views:

166

answers:

1

i'm using Haskell with the Yampa FRP library which uses the arrows language extension.

how can i do a simple putStrLn in a SF?

mySF = proc x -> do
    y <- identity -< x*x
    putStrLn "Hello World!" ++ show y
    returnA -< y

the arrow syntax complains about the expression not bein an arrow (of course), but even with arrows i get no output

 output <- identity -< putStrLn "Hello World!"
+4  A: 

I've only played around with Yampa a bit while trying to work through the FRP papers, but in my understanding this just isn't at all how you work with IO in Yampa. Instead you "animate" an SF a b with the reactimate function, which takes a function of type b -> IO () as its second argument. This function is where things like your putStrLn would live, along with any other kinds of rendering the program does.

The "Animating Signal Functions" section of the "Yampa Arcade" paper gives a good explanation of how reactimate works.

Travis Brown
so i have to collect all messages and print them in "actuate :: ... IO()"? is there no other way to create output/debug messages? this sounds very hard to debug...
@sisif: If you just want old-school "printf debugging", that's what `Debug.Trace` is for. For "real" output, the whole idea of FRP libraries is to separate time-varying, interactive logic from IO side effects.
camccann