ssm-lang / Scoria

This is an embedding of the Sparse Synchronous Model, in Haskell!
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

IO handlers #82

Closed Rewbert closed 3 years ago

Rewbert commented 3 years ago

IO handlers. I spoke with John and will let myself be guided by this example: this example.

I've begun by adding some new expression operators:

Rewbert commented 3 years ago

When requesting a LED the user is now given a reference to the LED and a handler that is to be scheduled. There is now a function schedule which is used to schedule the things that should populate the ready queue when the program begins. E.g

testprogram :: Compile ()
testprogram = do
    x <- switch 0
    y <- switch 1
    (z, handler) <- onoffLED 0

    let ?sw0 = x
        ?sw1 = y
        ?led_ctl = z

    schedule mmain
    schedule handler

By changing the ordering of schedule mmain and schedule handler you can change the eagerness with which the handler actually performs the LED IO.

Rewbert commented 3 years ago

So there is a lot going on in this PR. I will try to summarize the changes: