scala - Implementing snapshot in FRP -


i'm implementing frp framework in scala , seem have run problem. motivated thinking, question decided restrict public interface of framework behaviours evaluated in 'present' i.e.:

behaviour.at(now)  

this falls in line conal's assumption in fran paper behaviours ever evaluated/sampled @ increasing times. restrict transformations on behaviours otherwise find ourselves in huge problems behaviours represent input:

val slider = stepper(0, sliderchangeevent)  

with behaviour, evaluating future values incorrect , evaluating past values require unbounded amount of memory (all occurrences used in 'slider' event have stored).

i having trouble specification 'snapshot' operation on behaviours given restriction. problem best explained example (using slider mentioned above):

val event = mouseb // event occurs when mouse pressed  val sampler = slider.snapshot(event)  val stepper = stepper(0, sampler)  

my problem here if 'mouseb' event has occurred when code executed current value of 'stepper' last 'sample' of 'slider' (the value @ time last occurrence occurred). if time of last occurrence in past consequently end evaluating 'slider' using past time breaks rule set above (and original assumption). can see couple of ways solve this:

  1. we 'record' past (keep hold of past occurrences in event) allowing evaluation of behaviours past times (using unbounded amount of memory)
  2. we modify 'snapshot' take time argument ("sample after time") , enforce that time >=
  3. in more wacky move, restrict creation of frp objects initial setup of program somehow , start processing events/input after setup complete

i not implement 'sample' or remove 'stepper'/'switcher' (but don't want either of these things). has thoughts on this? have misunderstood here?

oh see mean now.

your "you can sample @ 'now'" restriction isn't tight enough, think. needs bit stronger avoid looking past. since using environmental conception of now, define behavior construction functions in terms of (so long now cannot advance mere execution of definitions, which, per last answer, messy). example:

stepper(i,e) behavior value i in interval [now,e1] (where e1 time of first occurrence of e after now), , value of recent occurrence of e afterward.

with semantics, prediction value of stepper got conundrum dismantled, , stepper have value 0. don't know whether semantics desirable you, seems natural enough me.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -