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 scontext ofclass (Monoid s, Real t) => HasTime t s | s -> t? What is it used for? - I was thinking of tacking on a
Map String Doublewith my sensor readings, but how should my monoid crunch the dictionaries? Should it be left-biased? Right-biased? None of the above?
If not, what am I supposed to do? I want to end up with wires of the form Wire s InhibitionReason Identity () Double for some s, representing my input.
It's my understanding that I don't want or need to use the monadic m parameter of Wire for this purpose, allowing the wires themselves to be pure and confining the IO to the code that steps through the top-level wire(s). Is this incorrect?
The simplest way to put data into a
Wire s e m a bis via the inputa. It's possible, through the use ofWPureorWGento get data out of the state deltasor the underlyingMonadm, but these take us further away from the main abstractions. The main abstractions areArrowandCategory, which only know abouta b, and not abouts e m.Here's an example of a very simple program, providing input as the input
a.doubleis the outermost wire of the program.replis a small read-eval-print loop that callsstepWireto run the wire.Notice that we pass in the time difference to
stepWire, not the total elapsed time. We can check that this is the correct thing to do by running a different top-level wire.Which has the desired output: