-
-
Save BenSchZA/57f1f46ec8e2ecc0f304ede813e5f4eb to your computer and use it in GitHub Desktop.
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
{-# LANGUAGE Arrows #-} | |
{-# LANGUAGE BlockArguments #-} | |
module Main where | |
import Control.Concurrent | |
import FRP.Yampa | |
data State = State { value :: Double } deriving (Show) | |
initialState = State 25.0 | |
cooling :: State -> SF () (State) | |
cooling state = (constant (-1) >>> integral) >>^ (+ value state) >>> arr (State) | |
coolingWithFloor :: State -> SF () (State) | |
coolingWithFloor state = switch cooling' atRoomTemp | |
where t' = cooling state | |
cooling' = ((arr (\_ -> t')) &&& ((\_ -> t') ^>> value ^>> (<= 18) ^>> edge >>^ (\e -> e `tag` t'))) | |
atRoomTemp _ = (constant 18) | |
main :: IO () | |
main = reactimate (return ()) | |
(\_ -> threadDelay 1 >> return (0.1, Nothing)) | |
(\_ b -> (putStrLn $ show b) >> return False) | |
(coolingWithFloor initialState) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The solution!