Created
March 5, 2018 13:27
-
-
Save FruitieX/39cab207e61ebd1b73585d4dc3c5d4b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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