Questions tagged [netwire]

Efficient and flexible wire arrows for functional reactive programming and other forms of locally stateful programming.

Netwire is a library for functional reactive programming, which uses the concept of arrows for modelling an embedded domain-specific language. This language lets you express reactive systems, which means systems that change over time. It shares the basic concept with Yampa and its fork Animas, but it is itself not a fork and has many additional features.

31 questions
27
votes
1 answer

Does push-pull FRP help when implementing games?

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 /…
Dan
  • 10,532
  • 2
  • 42
  • 74
11
votes
2 answers

Getting input into Netwire programs

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…
Doug McClean
  • 13,739
  • 4
  • 43
  • 68
9
votes
2 answers

"Behavior now" in FRP

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…
J. Abrahamson
  • 64,404
  • 8
  • 128
  • 172
8
votes
2 answers

What is the basic structure in Netwire 5?

I'm trying to get into Netwire, I've dug to find documentations, introductions, tutorials and whatnot, but just about every tutorial & existing-code is outdated as to Netwire 5 and uses functions from Netwire 4 that are just no longer with us. The…
MasterMastic
  • 19,099
  • 11
  • 59
  • 86
6
votes
2 answers

Convert from arrow notation

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…
Mokosha
  • 2,567
  • 14
  • 30
5
votes
1 answer

What invariants am I supposed to maintain when using Control.Wire.Unsafe.Event?

I'm using Netwire to write a program that is driven by events from the network. I guess there are three questions here: What makes Control.Wire.Unsafe.Event unsafe? Like the title says, what invariants do I need to maintain to use it safely? I…
Echo Nolan
  • 919
  • 12
  • 20
5
votes
2 answers

What can be a minimal example of game written in Haskell?

Update after three months I have an answer below using netwire-5.0.1 + sdl, in a structure of Functional Reactive Programming using Arrows and Kleisli Arrows for I/O. Though too simple to be called a "game", it should be very composible and very…
Carl Dong
  • 1,241
  • 13
  • 26
5
votes
1 answer

Correct use of Netwire (5)

I've been wanting to give FRP a shot for a while now, and yesterday I finally bit the bullet and had a go, using Netwire 5 to begin with (a fairly arbitrary choice in itself, but I have to start somewhere!). I've managed to get to the point of…
danielpwright
  • 667
  • 5
  • 9
5
votes
1 answer

Bumpless transfer in FRP

I can build a PID controller in the Haskell FRP library netwire using loop from the ArrowLoop instance provided for Wires. I can also implement switching between controllers or between a controller and a manual input using switch. How can I…
Doug McClean
  • 13,739
  • 4
  • 43
  • 68
5
votes
2 answers

Netwire 5 - bouncing object of the walls

I'm trying to understand FRP and Netwire. My best source of practical knowledge is this post, however it's a bit outdated, as it's written in Netwire 4, and I'm using version 5.0. I want to have player controlled square, that bounces off screen…
PL_kolek
  • 305
  • 3
  • 9
5
votes
3 answers

Haskell Netwire - Type errors

I have just started using netwire and I'm having trouble with the very basics. The following code works fine for me: main :: IO () main = testWire clockSession_ (for 3 . yeah) yeah :: Monad m => Wire s () m a String yeah = pure "yes" But this does…
functorial
  • 667
  • 5
  • 12
5
votes
1 answer

Netwire mutually dependant wires

To try out Netwire, I'm implementing Pong using the library. In the code I have a ball wire and a computer paddle wire, and since they depend on each other for some values I've been running into issues with infinite loops. Some pseudo-code to…
chanko08
  • 294
  • 1
  • 10
4
votes
2 answers

Is there a netwire equivalent of stepper?

Reactive-banana has a function named stepper (of type MonadMoment m => a -> Event a -> m (Behavior a)), which converts an event into a behaviour where the behaviour's value is the value of the last event, or the initial value if no event has…
Cameron Martin
  • 5,764
  • 1
  • 35
  • 52
4
votes
1 answer

Haskell Netwire: wires of wires done properly

I am trying to implement a dynamic set of wires in netwire 5 "properly". I've read the answer to wires of wires question, and I don't particularly like how the code in the example relies on the Event converted to a behaviour to show up non-empty on…
crosser
  • 649
  • 3
  • 17
4
votes
2 answers

Console interactivity in Netwire?

I am testing with the Netwire haskell library and made it work with a simple time wire: import Control.Wire import Prelude hiding ((.), id) import Control.Monad.IO.Class import Data.Functor.Identity import System.IO wire :: (HasTime t s) => Wire s…
Carl Dong
  • 1,241
  • 13
  • 26
1
2 3