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
4
votes
2 answers

Haskell Netwire: wires of wires

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…
bstamour
  • 7,534
  • 1
  • 21
  • 36
4
votes
1 answer

Misunderstanding ArrowLoop when used with Netwire

Following the lead of the excellent answer in this post, I'm trying to get a working example of ArrowLoop that doesn't use arrow notation. I'm uncomfortable using arrow notation until I fully understand how arrows work under the hood. That being…
Mokosha
  • 2,567
  • 14
  • 30
3
votes
1 answer

Kleisli Arrow in Netwire 5?

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…
Carl Dong
  • 1,241
  • 13
  • 26
3
votes
0 answers

Cloud Haskell & Netwire. Do they overlap? Can both be used effectively?

Basically, I want to experiment with FRP and distributed Haskell. I wonder if I could use Netwire for FRP and Cloud Haskell to allow "wires" to be distributed over different "nodes". But maybe Cloud Haskell already provides FRP. Or maybe Netwire…
Lay González
  • 2,765
  • 16
  • 34
3
votes
2 answers

Using netwire's periodic vs. at wires

I'm trying to write a framework for real-time interactive graphics in Haskell. I've been trying to get a handle on things by using Netwire 5, but I don't seem to have a good handle on how things "depend" on one another. For example, the following…
Mokosha
  • 2,567
  • 14
  • 30
3
votes
2 answers

Netwire - how to construct a wire that produces positions, bouncing of walls?

Using netwire-4.0.7 As the question title says, I'm trying to create a wire that produces positions (moving the position with a certain velocity in each step), "bouncing" off other objects. The simplest example I could think of was moving within a…
Cubic
  • 13,754
  • 4
  • 40
  • 81
2
votes
1 answer

Switching in Netwire

I've been looking for a while, and I think I'm misunderstanding something fundamental regarding switching. Consider the following code mywire :: HasTime t s => Wire s () IO a Int mywire = pure 10 mycont :: HasTime t s => Wire s () IO a (Wire s ()…
bstamour
  • 7,534
  • 1
  • 21
  • 36
2
votes
1 answer

netwire: dealing with laziness(?) in mutually dependent wires

I am trying to make objects bounce off the walls, using mutually dependent velocity and location wires. Simple one-dimentional example looks like this: {-# LANGUAGE Arrows #-} import Prelude hiding ((.), id) import Control.Wire import…
crosser
  • 649
  • 3
  • 17
2
votes
1 answer

Using Netwire to spawn lists from a value

I think I'm fundamentally misunderstanding how to attack this type of problem with Netwire: I have the following test-case: I'd like to take a string, split it into lines, print each line, then exit. The pieces I'm missing are: How to inhibit after…
Lyndon Maydwell
  • 177
  • 1
  • 8
2
votes
1 answer

Jumping mechanics in Netwire

I think I need some incentive on how to make this, I'm not really experienced in general platforming game mechanics... Anyway, my player figure has this up to now: movePlayer = proc p -> do let gravity = 100 sx <- keySpeed GLFW.LEFT…
Lanbo
  • 13,437
  • 14
  • 67
  • 141
1
vote
2 answers

Use of `periodic` in NetWire 5

Consider the following code: -- this defines what our 'state' will be data Direction = North | East | South | West deriving (Eq, Show, Enum) data State = State Int Bool Direction deriving (Show) initialState :: State initialState = State 0 True…
Rafael Ibraim
  • 1,485
  • 1
  • 12
  • 13
1
vote
1 answer

Is this a sensible way of collecting netwire inputs?

I would like use a wire of type Wire s e m a b to handle multiple inputs. The intended semantics would be If the input list is [] do nothing and return an empty list If the input list is a:as step the wire with input a, recursively step the…
Tom Ellis
  • 8,007
  • 21
  • 45
0
votes
1 answer

How to implement a collision with Netwire (5.0.1)

I am trying to model moving objects using Netwire and would like to know the recommended way to implement something like the bouncing of a ball off a wall. I have encountered several possible ways to do this and I need some help actually getting…
user668074
  • 1,029
  • 9
  • 14
0
votes
1 answer

Netwire 5 - A box cannot bounce

I am trying to convert challenge 3 ( https://ocharles.org.uk/blog/posts/2013-08-01-getting-started-with-netwire-and-sdl.html ) from netwire 4.0 to netwire 5.0 using OpenGL. Unfortunately, the box cannot bounce. The entire code is following. It seems…
0
votes
3 answers

Build a (Wire s e m a c) from (a -> b -> c) and (Wire s e m a b)

As a simple example I have this. import Prelude hiding ((.)) import FRP.Netwire import Control.Wire f :: Int -> Char -> String f = replicate w :: => Wire s e m Int Char w = mkSF_ fromInt where fromInt :: Int -> Char fromInt 1 =…
Alpaca
  • 642
  • 3
  • 11