netwire

Haskell Netwire: wires of wires

∥☆過路亽.° 提交于 2020-01-13 11:23:36
问题 I'm playing around with the netwire package trying to get a feel for FRP, and I have a quick question. Starting with the following simple wires, I'm able to emit an event every 5 seconds (approx) myWire :: (Monad m, HasTime t s) => Wire s () m a Float myWire = timeF myWire' :: (Monad m, HasTime t s) => Wire s () m a Int myWire' = fmap round myWire myEvent :: (Monad m, HasTime t s) => Wire s () m a (Event Int) myEvent = periodic 5 . myWire' This is pretty nice and straight forward, but what I

Does push-pull FRP help when implementing games?

孤街醉人 提交于 2019-12-20 09:30:19
问题 I've been comparing pull-only FRP (ie netwire) with push-pull FRP (ie reactive-bannana) in the implementation of games. Are there advantages to one over the other? Things I've notices are: Push events make it easy to have events for mouse clicks / key presses from GLFW or GLUT Arrowized FRP that netwire uses has much less IO floating around, which is always better. It looks like having pull-only responses to things like mouse movement could cause time leaks. What else have I missed? Edit, to

“Behavior now” in FRP

馋奶兔 提交于 2019-12-19 05:45:17
问题 In a previous SO question (Is it possible?: Behavior t [Behavior t a] -> Behavior t [a]) we were analyzing the existence of a Behavior join (to use reactive-banana terms). Behavior t (Behavior t a) -> Behavior t a Implemented in the semantic model as follows type Behavior t a = t -> a behaviorNow :: Behavior t (Behavior t a) -> Behavior t a behaviorNow f t = f t t While implementing this directly would be unfortunate since we could produce a Behavior Monad using const and behaviorNow , if and

Getting input into Netwire programs

若如初见. 提交于 2019-12-12 08:23:52
问题 I'm getting started with Netwire version 5. I have no problem writing all the wires I want to transform my inputs into my outputs. Now the time has come to write the IO wrapper to tie in my real-world inputs, and I am a bit confused. Am I supposed to create a custom session type for the s parameter of Wire s e m a b and embed my sensor values in there? If so, I have these questions: What's up with the Monoid s context of class (Monoid s, Real t) => HasTime t s | s -> t ? What is it used for?

Convert from arrow notation

故事扮演 提交于 2019-12-06 00:36:35
问题 I'm still trying to get a hang of the parallels between arrow notation and the semantics of the Arrow typeclasses defined in Haskell. In particular, this question seems to have a very canonical example of a small counter written with arrow notation: counter :: ArrowCircuit a => a Bool Int counter = proc reset -> do rec output <- returnA -< if reset then 0 else next next <- delay 0 -< output+1 returnA -< output Can someone show me how to convert this back into Haskell2010 without arrow

Convert from arrow notation

半城伤御伤魂 提交于 2019-12-04 06:11:50
I'm still trying to get a hang of the parallels between arrow notation and the semantics of the Arrow typeclasses defined in Haskell. In particular, this question seems to have a very canonical example of a small counter written with arrow notation: counter :: ArrowCircuit a => a Bool Int counter = proc reset -> do rec output <- returnA -< if reset then 0 else next next <- delay 0 -< output+1 returnA -< output Can someone show me how to convert this back into Haskell2010 without arrow notation? {- | +---------+ >Bool>--------------> | | >------------------>Int> +---------+ | arr f | /---->

Getting input into Netwire programs

人走茶凉 提交于 2019-12-04 01:15:43
I'm getting started with Netwire version 5. I have no problem writing all the wires I want to transform my inputs into my outputs. Now the time has come to write the IO wrapper to tie in my real-world inputs, and I am a bit confused. Am I supposed to create a custom session type for the s parameter of Wire s e m a b and embed my sensor values in there? If so, I have these questions: What's up with the Monoid s context of class (Monoid s, Real t) => HasTime t s | s -> t ? What is it used for? I was thinking of tacking on a Map String Double with my sensor readings, but how should my monoid

Does push-pull FRP help when implementing games?

女生的网名这么多〃 提交于 2019-12-02 18:57:56
I've been comparing pull-only FRP (ie netwire) with push-pull FRP (ie reactive-bannana) in the implementation of games. Are there advantages to one over the other? Things I've notices are: Push events make it easy to have events for mouse clicks / key presses from GLFW or GLUT Arrowized FRP that netwire uses has much less IO floating around, which is always better. It looks like having pull-only responses to things like mouse movement could cause time leaks. What else have I missed? Edit, to make this less opinion-based: The main goal is to have something that is as expressive/concise as

“Behavior now” in FRP

徘徊边缘 提交于 2019-12-01 03:36:44
In a previous SO question ( Is it possible?: Behavior t [Behavior t a] -> Behavior t [a] ) we were analyzing the existence of a Behavior join (to use reactive-banana terms). Behavior t (Behavior t a) -> Behavior t a Implemented in the semantic model as follows type Behavior t a = t -> a behaviorNow :: Behavior t (Behavior t a) -> Behavior t a behaviorNow f t = f t t While implementing this directly would be unfortunate since we could produce a Behavior Monad using const and behaviorNow , if and how does behaviorNow violate the semantics of FRP? I'd love to hear answers using the terminology of

Kleisli Arrow in Netwire 5?

淺唱寂寞╮ 提交于 2019-11-28 14:06:00
I am trying to create a game using Haskell + Netwire 5 (+ SDL). Now I am working on the output part, where I would like to create wires that read in some game state and output the SDL surfaces to be blitted on screen. However, the problem is that SDL surfaces are contained in IO monad, so any function that creates such surfaces must have type a -> IO b . Of course, arr does not construct a Wire from a -> m b . However, since the type signature of a wire is (Monad m, Monoid e) => Wire s e m a b , it looks quite like a Kleisi Arrow, but I cannot find a suitable constructor for making such a wire