Skip to content

Instantly share code, notes, and snippets.

@FruitieX
Created March 5, 2018 13:27
Show Gist options
  • Select an option

  • Save FruitieX/39cab207e61ebd1b73585d4dc3c5d4b2 to your computer and use it in GitHub Desktop.

Select an option

Save FruitieX/39cab207e61ebd1b73585d4dc3c5d4b2 to your computer and use it in GitHub Desktop.
setLight
:: forall e
. LuminaireId
-> LightId
-> LightColor
-> (Maybe Milliseconds)
-> Luminaires
-> Eff (ref :: REF, now :: NOW | e) Boolean
setLight id lid color transitionTime luminaires = do
light <- getLuminaireLight id lid luminaires
luminaire <- getLuminaire id luminaires
case light of
Just light' -> do
nextLight <- nextState light' color transitionTime
case luminaire of
Just luminaire' -> do
let curLights = _.lights (unwrap luminaire')
let nextLights = insert lid nextLight curLights
let nextLuminaire = wrap { gateway: _.gateway (unwrap luminaire'), lights: nextLights }
modifyRef luminaires
(\l -> insert id nextLuminaire l)
pure true
_ ->
pure false
_ ->
pure false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment