-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into updated-tutorial-systems
Need to fix refreshing
- Loading branch information
Showing
16 changed files
with
127 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,6 @@ setup.log | |
|
||
# Backup of opam lock file | ||
hazel.opam.locked.old | ||
|
||
# Code coverage | ||
_coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
open Core; | ||
open Bonsai; | ||
open Bonsai.Let_syntax; | ||
|
||
module Alarm = { | ||
module Action = { | ||
[@deriving sexp] | ||
type t = | ||
| SetAlarm(Time_ns.Alternate_sexp.t) | ||
| SnoozeAlarm(Time_ns.Alternate_sexp.t) | ||
| UnsetAlarm; | ||
}; | ||
|
||
let alarm = | ||
state_machine0( | ||
(module Time_ns.Alternate_sexp), | ||
(module Action), | ||
~default_model=Time_ns.max_value_representable, | ||
~apply_action=(~inject as _, ~schedule_event as _, model, action) => { | ||
switch (action) { | ||
| SetAlarm(time) => time | ||
| SnoozeAlarm(time) => Time_ns.max(time, model) | ||
| UnsetAlarm => Time_ns.max_value_representable | ||
} | ||
}); | ||
|
||
let listen = (alarm, ~event) => { | ||
let%sub before_or_after = Clock.at(alarm |> Value.map(~f=fst)); | ||
Edge.on_change( | ||
(module Clock.Before_or_after), | ||
before_or_after, | ||
~callback={ | ||
open Clock.Before_or_after; | ||
let%map (_, inject) = alarm | ||
and event = event; | ||
fun | ||
| After => Effect.Many([inject(Action.UnsetAlarm), event]) | ||
| Before => Effect.Ignore; | ||
}, | ||
); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters