Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

-- base
import Control.Concurrent (threadDelay)
import Control.Monad.Fail
import Data.Either (rights)
import System.IO (hFlush, stdout)
import Text.Read (readMaybe)
Expand All @@ -17,7 +18,7 @@ import Control.Monad.Trans.MSF.Maybe (runMaybeT, MaybeT, exit)

-- rhine
import FRP.Rhine
import FRP.Rhine.SyncSF.Except
import FRP.Rhine.ClSF.Except
import FRP.Rhine.Clock.Realtime.Millisecond
import FRP.Rhine.Clock.Realtime.Stdin
import FRP.Rhine.Clock.Select
Expand All @@ -41,5 +42,5 @@ mainRhine = timeless (listToMaybeS "Congratulations! You've installed the tuto


-- TODO In dunai 0.1.2
listToMaybeS :: Monad m => [b] -> MSF (MaybeT m) a b
listToMaybeS :: MonadFail m => [b] -> MSF (MaybeT m) a b
listToMaybeS = foldr iPost exit
19 changes: 9 additions & 10 deletions PresentationExamples.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

-- dunai
import Data.MonadicStreamFunction
import Data.VectorSpace.Specific()

-- rhine
import FRP.Rhine
import FRP.Rhine.SyncSF.Except
import FRP.Rhine.ClSF.Except
import FRP.Rhine.Clock.Realtime.Millisecond

---------------------------
Expand All @@ -31,13 +30,13 @@ main1 = reactimate

type SumClock = Millisecond 100

fillUp :: Monad m => SyncSF (ExceptT Double m) SumClock Double ()
fillUp :: Monad m => ClSF (ExceptT Double m) SumClock Double ()
fillUp = proc x -> do
s <- integral -< x
_ <- throwOn' -< (s > 5, s)
returnA -< ()

helloWorld :: SyncExcept IO SumClock () () Empty

helloWorld = do
try $ arr (const 1) >>> fillUp
once_ $ putStrLn "Hello World!"
Expand All @@ -49,20 +48,20 @@ main = flow $ safely helloWorld @@ waitClock

data FastClock = FastClock
instance Clock m FastClock where
type TimeDomainOf FastClock = ()
type Time FastClock = ()
type Tag FastClock = ()
startClock = undefined
initClock = undefined

data SlowClock = SlowClock
instance Clock m SlowClock where
type TimeDomainOf SlowClock = ()
type Time SlowClock = ()
type Tag SlowClock = ()
startClock = undefined
initClock = undefined

fastSignal :: SyncSF m FastClock () a
fastSignal :: ClSF m FastClock () a
fastSignal = undefined

slowProcessor :: SyncSF m SlowClock b c
slowProcessor :: ClSF m SlowClock b c
slowProcessor = undefined

-- uncomment the following for a clock type error
Expand Down
6 changes: 3 additions & 3 deletions Util.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Util where

-- dunai
import Control.Monad.Fail-- dunai
import Control.Monad.Trans.MSF.Except
import Data.MonadicStreamFunction

-- | Accumulates inputs and starts an MSF for each of them
pool :: Monad m => (a -> MSF m () b) -> MSF m [a] [b]
pool :: MonadFail m => (a -> MSF m () b) -> MSF m [a] [b]
pool f = pool' f []
where
pool' :: Monad m => (a -> MSF m () b) -> [MSF m () b] -> MSF m [a] [b]
Expand All @@ -15,7 +15,7 @@ pool f = pool' f []
return (bs, pool' f msfs')

-- | Remembers and indefinitely outputs the first input value.
keepFirst :: Monad m => MSF m a a
keepFirst :: MonadFail m => MSF m a a
keepFirst = safely $ do
a <- try throwS
safe $ arr $ const a
Expand Down
8 changes: 4 additions & 4 deletions rhine-tutorial.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ executable rhine-tutorial
other-modules: Util
-- other-extensions:
build-depends: base >= 4.8 && < 5
, dunai == 0.3.*
, rhine == 0.3.*
, dunai
, rhine
, transformers == 0.5.* && < 0.6
-- hs-source-dirs:
default-language: Haskell2010
Expand All @@ -30,8 +30,8 @@ executable presentation-examples
main-is: PresentationExamples.hs
-- other-extensions:
build-depends: base >= 4.8 && < 5
, dunai == 0.3.*
, rhine == 0.3.*
, dunai
, rhine
, transformers == 0.5.* && < 0.6
-- hs-source-dirs:
default-language: Haskell2010
13 changes: 13 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#resolver: nightly-2018-10-12
resolver: lts-12.11
extra-deps:
- git: https://github.com/0xCM/rhine.git
commit: 772f913d8fda51b0a0c2ad8b303859fdb7d3863c
subdirs:
- rhine
- git: https://github.com/0xCM/dunai.git
commit: 5505a15b2009e13e233cca8328d520442d3045c6
- git: https://github.com/expipiplus1/vector-sized.git
commit: f80e3ce774d255ee4ba25fcb12a81a76f600e0b0
- finite-typelits-0.1.4.2@sha256:d243523297c0526d32e9b7de98e04b79a4227577ddb25d3fecd7981439de243c
- indexed-list-literals-0.2.1.2@sha256:0760e2a86605b5557af7180d4d50e317d75a5a92ca12aaabb6948ce97b7a94ac