{-# LANGUAGE Arrows #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
module FRP.Rhine.ClSF.Core (
module FRP.Rhine.ClSF.Core,
module Control.Arrow,
module X,
)
where
import Control.Arrow
import Control.Monad.Trans.Class
import Control.Monad.Trans.Reader (ReaderT, mapReaderT, withReaderT)
import Data.Automaton as X
import FRP.Rhine.Clock
type ClSF m cl a b = Automaton (ReaderT (TimeInfo cl) m) a b
type ClSignal m cl a = forall arbitrary. ClSF m cl arbitrary a
type Behaviour m time a = forall cl. (time ~ Time cl) => ClSignal m cl a
type Behavior m time a = Behaviour m time a
type BehaviourF m time a b = forall cl. (time ~ Time cl) => ClSF m cl a b
type BehaviorF m time a b = BehaviourF m time a b
hoistClSF ::
(Monad m1, Monad m2) =>
(forall c. m1 c -> m2 c) ->
ClSF m1 cl a b ->
ClSF m2 cl a b
hoistClSF :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) cl a b.
(Monad m1, Monad m2) =>
(forall c. m1 c -> m2 c) -> ClSF m1 cl a b -> ClSF m2 cl a b
hoistClSF forall c. m1 c -> m2 c
hoist = (forall x.
ReaderT (TimeInfo cl) m1 x -> ReaderT (TimeInfo cl) m2 x)
-> Automaton (ReaderT (TimeInfo cl) m1) a b
-> Automaton (ReaderT (TimeInfo cl) m2) a b
forall (m :: Type -> Type) (n :: Type -> Type) a b.
Monad m =>
(forall x. m x -> n x) -> Automaton m a b -> Automaton n a b
hoistS ((forall x.
ReaderT (TimeInfo cl) m1 x -> ReaderT (TimeInfo cl) m2 x)
-> Automaton (ReaderT (TimeInfo cl) m1) a b
-> Automaton (ReaderT (TimeInfo cl) m2) a b)
-> (forall x.
ReaderT (TimeInfo cl) m1 x -> ReaderT (TimeInfo cl) m2 x)
-> Automaton (ReaderT (TimeInfo cl) m1) a b
-> Automaton (ReaderT (TimeInfo cl) m2) a b
forall a b. (a -> b) -> a -> b
$ (m1 x -> m2 x)
-> ReaderT (TimeInfo cl) m1 x -> ReaderT (TimeInfo cl) m2 x
forall (m :: Type -> Type) a (n :: Type -> Type) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT m1 x -> m2 x
forall c. m1 c -> m2 c
hoist
hoistClSFAndClock ::
(Monad m1, Monad m2) =>
(forall c. m1 c -> m2 c) ->
ClSF m1 cl a b ->
ClSF m2 (HoistClock m1 m2 cl) a b
hoistClSFAndClock :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) cl a b.
(Monad m1, Monad m2) =>
(forall c. m1 c -> m2 c)
-> ClSF m1 cl a b -> ClSF m2 (HoistClock m1 m2 cl) a b
hoistClSFAndClock forall c. m1 c -> m2 c
hoist =
(forall x.
ReaderT (TimeInfo cl) m1 x
-> ReaderT (TimeInfo (HoistClock m1 m2 cl)) m2 x)
-> Automaton (ReaderT (TimeInfo cl) m1) a b
-> Automaton (ReaderT (TimeInfo (HoistClock m1 m2 cl)) m2) a b
forall (m :: Type -> Type) (n :: Type -> Type) a b.
Monad m =>
(forall x. m x -> n x) -> Automaton m a b -> Automaton n a b
hoistS ((forall x.
ReaderT (TimeInfo cl) m1 x
-> ReaderT (TimeInfo (HoistClock m1 m2 cl)) m2 x)
-> Automaton (ReaderT (TimeInfo cl) m1) a b
-> Automaton (ReaderT (TimeInfo (HoistClock m1 m2 cl)) m2) a b)
-> (forall x.
ReaderT (TimeInfo cl) m1 x
-> ReaderT (TimeInfo (HoistClock m1 m2 cl)) m2 x)
-> Automaton (ReaderT (TimeInfo cl) m1) a b
-> Automaton (ReaderT (TimeInfo (HoistClock m1 m2 cl)) m2) a b
forall a b. (a -> b) -> a -> b
$ (TimeInfo (HoistClock m1 m2 cl) -> TimeInfo cl)
-> ReaderT (TimeInfo cl) m2 x
-> ReaderT (TimeInfo (HoistClock m1 m2 cl)) m2 x
forall r' r (m :: Type -> Type) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT ((Tag (HoistClock m1 m2 cl) -> Tag cl)
-> TimeInfo (HoistClock m1 m2 cl) -> TimeInfo cl
forall cl1 cl2.
(Time cl1 ~ Time cl2) =>
(Tag cl1 -> Tag cl2) -> TimeInfo cl1 -> TimeInfo cl2
retag Tag cl -> Tag cl
Tag (HoistClock m1 m2 cl) -> Tag cl
forall a. a -> a
id) (ReaderT (TimeInfo cl) m2 x
-> ReaderT (TimeInfo (HoistClock m1 m2 cl)) m2 x)
-> (ReaderT (TimeInfo cl) m1 x -> ReaderT (TimeInfo cl) m2 x)
-> ReaderT (TimeInfo cl) m1 x
-> ReaderT (TimeInfo (HoistClock m1 m2 cl)) m2 x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (m1 x -> m2 x)
-> ReaderT (TimeInfo cl) m1 x -> ReaderT (TimeInfo cl) m2 x
forall (m :: Type -> Type) a (n :: Type -> Type) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT m1 x -> m2 x
forall c. m1 c -> m2 c
hoist
liftClSF ::
(Monad m, MonadTrans t, Monad (t m)) =>
ClSF m cl a b ->
ClSF (t m) cl a b
liftClSF :: forall (m :: Type -> Type) (t :: (Type -> Type) -> Type -> Type) cl
a b.
(Monad m, MonadTrans t, Monad (t m)) =>
ClSF m cl a b -> ClSF (t m) cl a b
liftClSF = (forall c. m c -> t m c) -> ClSF m cl a b -> ClSF (t m) cl a b
forall (m1 :: Type -> Type) (m2 :: Type -> Type) cl a b.
(Monad m1, Monad m2) =>
(forall c. m1 c -> m2 c) -> ClSF m1 cl a b -> ClSF m2 cl a b
hoistClSF m c -> t m c
forall c. m c -> t m c
forall (m :: Type -> Type) a. Monad m => m a -> t m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift
liftClSFAndClock ::
(Monad m, MonadTrans t, Monad (t m)) =>
ClSF m cl a b ->
ClSF (t m) (LiftClock m t cl) a b
liftClSFAndClock :: forall (m :: Type -> Type) (t :: (Type -> Type) -> Type -> Type) cl
a b.
(Monad m, MonadTrans t, Monad (t m)) =>
ClSF m cl a b -> ClSF (t m) (LiftClock m t cl) a b
liftClSFAndClock = (forall c. m c -> t m c)
-> ClSF m cl a b -> ClSF (t m) (HoistClock m (t m) cl) a b
forall (m1 :: Type -> Type) (m2 :: Type -> Type) cl a b.
(Monad m1, Monad m2) =>
(forall c. m1 c -> m2 c)
-> ClSF m1 cl a b -> ClSF m2 (HoistClock m1 m2 cl) a b
hoistClSFAndClock m c -> t m c
forall c. m c -> t m c
forall (m :: Type -> Type) a. Monad m => m a -> t m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift
timeless :: (Monad m) => Automaton m a b -> ClSF m cl a b
timeless :: forall (m :: Type -> Type) a b cl.
Monad m =>
Automaton m a b -> ClSF m cl a b
timeless = Automaton m a b -> Automaton (ReaderT (TimeInfo cl) m) a b
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a
b.
(MonadTrans t, Monad m, Functor (t m)) =>
Automaton m a b -> Automaton (t m) a b
liftS
arrMCl :: (Monad m) => (a -> m b) -> ClSF m cl a b
arrMCl :: forall (m :: Type -> Type) a b cl.
Monad m =>
(a -> m b) -> ClSF m cl a b
arrMCl = Automaton m a b -> ClSF m cl a b
forall (m :: Type -> Type) a b cl.
Monad m =>
Automaton m a b -> ClSF m cl a b
timeless (Automaton m a b -> ClSF m cl a b)
-> ((a -> m b) -> Automaton m a b) -> (a -> m b) -> ClSF m cl a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> m b) -> Automaton m a b
forall (m :: Type -> Type) a b.
Functor m =>
(a -> m b) -> Automaton m a b
arrM
constMCl :: (Monad m) => m b -> ClSF m cl a b
constMCl :: forall (m :: Type -> Type) b cl a. Monad m => m b -> ClSF m cl a b
constMCl = Automaton m a b -> ClSF m cl a b
forall (m :: Type -> Type) a b cl.
Monad m =>
Automaton m a b -> ClSF m cl a b
timeless (Automaton m a b -> ClSF m cl a b)
-> (m b -> Automaton m a b) -> m b -> ClSF m cl a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m b -> Automaton m a b
forall (m :: Type -> Type) b a. Functor m => m b -> Automaton m a b
constM
mapMaybe ::
(Monad m) =>
ClSF m cl a b ->
ClSF m cl (Maybe a) (Maybe b)
mapMaybe :: forall (m :: Type -> Type) cl a b.
Monad m =>
ClSF m cl a b -> ClSF m cl (Maybe a) (Maybe b)
mapMaybe ClSF m cl a b
behaviour = proc Maybe a
ma -> case Maybe a
ma of
Maybe a
Nothing -> Automaton (ReaderT (TimeInfo cl) m) (Maybe b) (Maybe b)
forall (a :: Type -> Type -> Type) b. Arrow a => a b b
returnA -< Maybe b
forall a. Maybe a
Nothing
Just a
a -> (b -> Maybe b) -> Automaton (ReaderT (TimeInfo cl) m) b (Maybe b)
forall b c. (b -> c) -> Automaton (ReaderT (TimeInfo cl) m) b c
forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr b -> Maybe b
forall a. a -> Maybe a
Just Automaton (ReaderT (TimeInfo cl) m) b (Maybe b)
-> ClSF m cl a b -> Automaton (ReaderT (TimeInfo cl) m) a (Maybe b)
forall {k} (cat :: k -> k -> Type) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
<<< ClSF m cl a b
behaviour -< a
a