-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An asynchronous modal FRP language for GUI programming -- -- This library implements an experimental variant of the Async Rattus -- programming language that features extensions for implementing GUIs. A -- comprehensive introduction can be found in this paper. -- -- Several example GUIs implemented using Widget Rattus can be found -- here. @package WidgetRattus @version 0.3 module WidgetRattus.InternalPrimitives type InputChannelIdentifier = Int type Clock = IntSet singletonClock :: InputChannelIdentifier -> Clock emptyClock :: Clock clockUnion :: Clock -> Clock -> Clock channelMember :: InputChannelIdentifier -> Clock -> Bool data InputValue [OneInput] :: !InputChannelIdentifier -> !a -> InputValue [MoreInputs] :: !InputChannelIdentifier -> !a -> !InputValue -> InputValue inputInClock :: InputValue -> Clock -> Bool -- | The "later" type modality. A value v of type O 𝜏 -- consists of two components: Its clock, denoted cl(v), and a -- delayed computation that will produce a value of type 𝜏 as -- soon as the clock cl(v) ticks. The clock cl(v) is -- only used for type checking and is not directly accessible, whereas -- the delayed computation is accessible via adv and -- select. data O a Delay :: !Clock -> (InputValue -> a) -> O a -- | The return type of the select primitive. data Select a b Fst :: !a -> !O b -> Select a b Snd :: !O a -> !b -> Select a b Both :: !a -> !b -> Select a b rattusError :: [Char] -> a -- | This is the constructor for the "later" modality O: -- --
-- Γ ✓θ ⊢ t :: 𝜏 -- -------------------- -- Γ ⊢ delay t :: O 𝜏 ---- -- The typing rule requires that its argument t typecheck with -- an additional tick ✓θ of some clock θ. delay :: a -> O a extractClock :: O a -> Clock adv' :: O a -> InputValue -> a -- | This is the eliminator for the "later" modality O: -- --
-- Γ ⊢ t :: O 𝜏 Γ' tick-free -- --------------------------------- -- Γ ✓cl(t) Γ' ⊢ adv t :: 𝜏 ---- -- It requires that a tick ✓θ is in the context whose clock -- matches exactly the clock of t, i.e. θ = cl(t). adv :: O a -> a -- | If we want to eliminate more than one delayed computation, i.e. two -- s :: O σ and t :: O 𝜏, we need to use select -- instead of just adv. -- --
-- Γ ⊢ s :: O σ Γ ⊢ t :: O 𝜏 Γ' tick-free -- -------------------------------------------------- -- Γ ✓cl(s)⊔cl(t) Γ' ⊢ select s t :: Select σ 𝜏 ---- -- It requires that we have a tick ✓θ in the context whose clock -- matches the union of the clocks of s and t, i.e. -- θ = cl(s)⊔cl(t). The union of two clocks ticks whenever -- either of the two clocks ticks, i.e. cl(s)⊔cl(t), whenever -- cl(s) or cl(t) ticks. -- -- That means there are three possible outcomes, which are reflected in -- the result type of select s t. A value of Select σ 𝜏 -- is either -- --
-- Γ☐ ⊢ t :: 𝜏 -- -------------------- -- Γ ⊢ box t :: Box 𝜏 ---- -- where Γ☐ is obtained from Γ by removing all ticks and all variables -- x :: 𝜏, where 𝜏 is not a stable type. box :: a -> Box a -- | This is the eliminator for the "stable" modality Box: -- --
-- Γ ⊢ t :: Box 𝜏 -- ------------------ -- Γ ⊢ unbox t :: 𝜏 --unbox :: Box a -> a defaultPromote :: Continuous a => a -> Box a class Continuous p -- | Computes the same as progressInternal and nextProgress. -- In particular progressAndNext inp v = (progressInternal inp v, -- nextProgress (progressInternal inp v)). progressAndNext :: Continuous p => InputValue -> p -> (p, Clock) -- | Progresses the continuous value, given the input value from some -- channel progressInternal :: Continuous p => InputValue -> p -> p -- | Computes the set of channels that the continuous value is depending -- on. That is if nextProgress v = cl and a new input -- inp on channel ch arrives, then progressInternal -- inp v = v if not (ch channelMember cl). nextProgress :: Continuous p => p -> Clock promoteInternal :: Continuous p => p -> Box p data ContinuousData [ContinuousData] :: Continuous a => !Weak (IORef a) -> ContinuousData promoteStore :: IORef [ContinuousData] progressPromoteStoreMutex :: MVar () -- | Atomic version of progressPromoteStore. progressPromoteStoreAtomic :: InputValue -> IO () -- | For promote to work, its argument must be stored in the "promote -- store", and whenenver an input is received on some channel, all values -- in the "promote store" must be advanced (using -- progressInternal). progressPromoteStore :: InputValue -> IO () promote :: Continuous a => a -> Box a newtype Chan a Chan :: InputChannelIdentifier -> Chan a instance WidgetRattus.InternalPrimitives.Stable a => WidgetRattus.InternalPrimitives.Continuous a module WidgetRattus.Plugin.Annotation -- | By default all Async Rattus functions are checked for use of lazy data -- types, since these may cause memory leaks. If any lazy data types are -- used, a warning is issued. These warnings can be disabled by -- annotating the module or the function with AllowLazyData -- --
-- {-# ANN myFunction AllowLazyData #-}
--
-- {-# ANN module AllowLazyData #-}
--
--
-- Async Rattus only allows guarded recursion, i.e. recursive calls must
-- occur in the scope of a tick. Structural recursion over strict data
-- types is safe as well, but is currently not checked. To disable the
-- guarded recursion check, annotate the module or function with
-- AllowRecursion.
--
--
-- {-# ANN myFunction AllowRecursion #-}
--
-- {-# ANN module AllowRecursion #-}
--
data WidgetRattus
AllowLazyData :: WidgetRattus
AllowRecursion :: WidgetRattus
-- | This annotation type is for internal use only.
data InternalAnn
ExpectError :: InternalAnn
ExpectWarning :: InternalAnn
instance GHC.Classes.Eq WidgetRattus.Plugin.Annotation.WidgetRattus
instance GHC.Classes.Ord WidgetRattus.Plugin.Annotation.WidgetRattus
instance GHC.Show.Show WidgetRattus.Plugin.Annotation.WidgetRattus
instance Data.Data.Data WidgetRattus.Plugin.Annotation.WidgetRattus
instance GHC.Classes.Ord WidgetRattus.Plugin.Annotation.InternalAnn
instance GHC.Classes.Eq WidgetRattus.Plugin.Annotation.InternalAnn
instance GHC.Show.Show WidgetRattus.Plugin.Annotation.InternalAnn
instance Data.Data.Data WidgetRattus.Plugin.Annotation.InternalAnn
-- | The plugin to make it all work.
module WidgetRattus.Plugin
-- | Use this to enable Asynchronous Rattus' plugin, either by supplying
-- the option -fplugin=WidgetRattus.Plugin directly to GHC, or
-- by including the following pragma in each source file:
--
--
-- {-# OPTIONS -fplugin=WidgetRattus.Plugin #-}
--
plugin :: Plugin
-- | By default all Async Rattus functions are checked for use of lazy data
-- types, since these may cause memory leaks. If any lazy data types are
-- used, a warning is issued. These warnings can be disabled by
-- annotating the module or the function with AllowLazyData
--
--
-- {-# ANN myFunction AllowLazyData #-}
--
-- {-# ANN module AllowLazyData #-}
--
--
-- Async Rattus only allows guarded recursion, i.e. recursive calls must
-- occur in the scope of a tick. Structural recursion over strict data
-- types is safe as well, but is currently not checked. To disable the
-- guarded recursion check, annotate the module or function with
-- AllowRecursion.
--
--
-- {-# ANN myFunction AllowRecursion #-}
--
-- {-# ANN module AllowRecursion #-}
--
data WidgetRattus
AllowLazyData :: WidgetRattus
AllowRecursion :: WidgetRattus
-- | The language primitives of Async Rattus. Note that the typing rules
-- for delay, adv,select and box are more
-- restrictive than the Haskell types that are indicated. The stricter
-- Async Rattus typing rules for these primitives are given below.
module WidgetRattus.Primitives
-- | The "later" type modality. A value v of type O 𝜏
-- consists of two components: Its clock, denoted cl(v), and a
-- delayed computation that will produce a value of type 𝜏 as
-- soon as the clock cl(v) ticks. The clock cl(v) is
-- only used for type checking and is not directly accessible, whereas
-- the delayed computation is accessible via adv and
-- select.
data O a
-- | The "stable" type modality. A value of type Box a is a
-- time-independent computation that produces a value of type a.
-- Use box and unbox to construct and consume
-- Box-types.
data Box a
-- | The return type of the select primitive.
data Select a b
Fst :: !a -> !O b -> Select a b
Snd :: !O a -> !b -> Select a b
Both :: !a -> !b -> Select a b
-- | This is the constructor for the "later" modality O:
--
-- -- Γ ✓θ ⊢ t :: 𝜏 -- -------------------- -- Γ ⊢ delay t :: O 𝜏 ---- -- The typing rule requires that its argument t typecheck with -- an additional tick ✓θ of some clock θ. delay :: a -> O a -- | This is the eliminator for the "later" modality O: -- --
-- Γ ⊢ t :: O 𝜏 Γ' tick-free -- --------------------------------- -- Γ ✓cl(t) Γ' ⊢ adv t :: 𝜏 ---- -- It requires that a tick ✓θ is in the context whose clock -- matches exactly the clock of t, i.e. θ = cl(t). adv :: O a -> a promote :: Continuous a => a -> Box a -- | This is the constructor for the "stable" modality Box: -- --
-- Γ☐ ⊢ t :: 𝜏 -- -------------------- -- Γ ⊢ box t :: Box 𝜏 ---- -- where Γ☐ is obtained from Γ by removing all ticks and all variables -- x :: 𝜏, where 𝜏 is not a stable type. box :: a -> Box a -- | This is the eliminator for the "stable" modality Box: -- --
-- Γ ⊢ t :: Box 𝜏 -- ------------------ -- Γ ⊢ unbox t :: 𝜏 --unbox :: Box a -> a -- | If we want to eliminate more than one delayed computation, i.e. two -- s :: O σ and t :: O 𝜏, we need to use select -- instead of just adv. -- --
-- Γ ⊢ s :: O σ Γ ⊢ t :: O 𝜏 Γ' tick-free -- -------------------------------------------------- -- Γ ✓cl(s)⊔cl(t) Γ' ⊢ select s t :: Select σ 𝜏 ---- -- It requires that we have a tick ✓θ in the context whose clock -- matches the union of the clocks of s and t, i.e. -- θ = cl(s)⊔cl(t). The union of two clocks ticks whenever -- either of the two clocks ticks, i.e. cl(s)⊔cl(t), whenever -- cl(s) or cl(t) ticks. -- -- That means there are three possible outcomes, which are reflected in -- the result type of select s t. A value of Select σ 𝜏 -- is either -- --
-- fromListN (length xs) xs == fromList xs --fromListN :: IsList l => Int -> [Item l] -> l -- | The toList function extracts a list of Item l from the -- structure l. It should satisfy fromList . toList = id. toList :: IsList l => l -> [Item l] -- | Remove the last element from a list if there is one, otherwise return -- Nil. init' :: List a -> List a -- | Reverse a list. reverse' :: List a -> List a union' :: Eq a => List a -> List a -> List a unionBy' :: (a -> a -> Bool) -> List a -> List a -> List a nub' :: Eq a => List a -> List a nubBy' :: (a -> a -> Bool) -> List a -> List a filter' :: (a -> Bool) -> List a -> List a delete' :: Eq a => a -> List a -> List a deleteBy' :: (a -> a -> Bool) -> a -> List a -> List a -- | Append two lists. (+++) :: List a -> List a -> List a -- | Returns Nothing' on an empty list or Just' -- a where a is the first element of the list. listToMaybe' :: List a -> Maybe' a map' :: (a -> b) -> List a -> List b zip' :: List a -> List b -> List (a :* b) zipWith' :: (a -> b -> c) -> List a -> List b -> List c -- | A version of map which can throw out elements. In particular, -- the function argument returns something of type Maybe' -- b. If this is Nothing', no element is added on to the -- result list. If it is Just' b, then b is -- included in the result list. mapMaybe' :: (a -> Maybe' b) -> List a -> List b concatMap' :: (a -> List b) -> List a -> List b -- | Strict pair type. data a :* b (:*) :: !a -> !b -> (:*) a b infixr 2 :* infixr 2 :* -- | Strict variant of Maybe. data Maybe' a Just' :: !a -> Maybe' a Nothing' :: Maybe' a -- | takes a default value, a function, and a Maybe' value. If the -- Maybe' value is Nothing', the function returns the -- default value. Otherwise, it applies the function to the value inside -- the Just' and returns the result. maybe' :: b -> (a -> b) -> Maybe' a -> b fromMaybe' :: a -> Maybe' a -> a isJust' :: Maybe' a -> Bool -- | First projection function. fst' :: (a :* b) -> a -- | Second projection function. snd' :: (a :* b) -> b curry' :: ((a :* b) -> c) -> a -> b -> c uncurry' :: (a -> b -> c) -> (a :* b) -> c toText :: Show a => a -> Text readMaybe' :: Read a => Text -> Maybe' a splitOn' :: Text -> Text -> List Text instance WidgetRattus.InternalPrimitives.Continuous a => WidgetRattus.InternalPrimitives.Continuous (WidgetRattus.Strict.Maybe' a) instance GHC.Classes.Ord a => GHC.Classes.Ord (WidgetRattus.Strict.Maybe' a) instance GHC.Classes.Eq a => GHC.Classes.Eq (WidgetRattus.Strict.Maybe' a) instance GHC.Show.Show a => GHC.Show.Show (WidgetRattus.Strict.Maybe' a) instance WidgetRattus.InternalPrimitives.Continuous a => WidgetRattus.InternalPrimitives.Continuous (WidgetRattus.Strict.List a) instance Data.Traversable.Traversable WidgetRattus.Strict.List instance GHC.IsList.IsList (WidgetRattus.Strict.List a) instance Data.Foldable.Foldable WidgetRattus.Strict.List instance GHC.Base.Functor WidgetRattus.Strict.List instance GHC.Classes.Eq a => GHC.Classes.Eq (WidgetRattus.Strict.List a) instance GHC.Show.Show a => GHC.Show.Show (WidgetRattus.Strict.List a) instance (WidgetRattus.InternalPrimitives.Continuous a, WidgetRattus.InternalPrimitives.Continuous b) => WidgetRattus.InternalPrimitives.Continuous (a WidgetRattus.Strict.:* b) instance GHC.Base.Functor ((WidgetRattus.Strict.:*) a) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (a WidgetRattus.Strict.:* b) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (a WidgetRattus.Strict.:* b) instance (Data.VectorSpace.VectorSpace v a, Data.VectorSpace.VectorSpace w a, GHC.Float.Floating a, GHC.Classes.Eq a) => Data.VectorSpace.VectorSpace (v WidgetRattus.Strict.:* w) a module WidgetRattus.Channels -- | timer n produces a delayed computation that ticks every -- n milliseconds. In particular mkSig (timer n) is a -- signal that produces a new value every milliseconds. timer :: Int -> Box (O ()) -- | A type p satisfying Producer p a is essentially a -- signal that produces values of type a but it might not -- produce such values at each tick. class Producer p a | p -> a -- | Get the current value of the producer if any. getCurrent :: Producer p a => p -> Maybe' a -- | Get the next state of the producer. Morally, the type of this method -- should be -- --
-- getNext :: p -> (exists q. Producer q a => O q) ---- -- We encode the existential type using continuation-passing style. getNext :: Producer p a => p -> (forall q. Producer q a => O q -> b) -> b chan :: C (Chan a) newtype C a C :: IO a -> C a [unC] :: C a -> IO a delayC :: O (C a) -> C (O a) wait :: Chan a -> O a data Chan a instance GHC.Base.Monad WidgetRattus.Channels.C instance GHC.Base.Applicative WidgetRattus.Channels.C instance GHC.Base.Functor WidgetRattus.Channels.C instance WidgetRattus.Channels.Producer p a => WidgetRattus.Channels.Producer (WidgetRattus.InternalPrimitives.O p) a instance WidgetRattus.Channels.Producer p a => WidgetRattus.Channels.Producer (WidgetRattus.InternalPrimitives.Box p) a -- | The bare-bones Asynchronous Rattus language. To program with streams, -- you can use WidgetRattus.Stream. module WidgetRattus continuous :: Name -> Q [Dec] -- | By default all Async Rattus functions are checked for use of lazy data -- types, since these may cause memory leaks. If any lazy data types are -- used, a warning is issued. These warnings can be disabled by -- annotating the module or the function with AllowLazyData -- --
-- {-# ANN myFunction AllowLazyData #-}
--
-- {-# ANN module AllowLazyData #-}
--
--
-- Async Rattus only allows guarded recursion, i.e. recursive calls must
-- occur in the scope of a tick. Structural recursion over strict data
-- types is safe as well, but is currently not checked. To disable the
-- guarded recursion check, annotate the module or function with
-- AllowRecursion.
--
--
-- {-# ANN myFunction AllowRecursion #-}
--
-- {-# ANN module AllowRecursion #-}
--
data WidgetRattus
AllowLazyData :: WidgetRattus
AllowRecursion :: WidgetRattus
mapO :: Box (a -> b) -> O a -> O b
-- | Programming with signals.
module WidgetRattus.Signal
-- | Apply a function to the value of a signal.
map :: Box (a -> b) -> Sig a -> Sig b
-- | A version of map for delayed signals.
mapAwait :: Box (a -> b) -> O (Sig a) -> O (Sig b)
-- | This function allows to switch from one signal to another one
-- dynamically. The signal defined by switch xs ys first behaves
-- like xs, but as soon as ys produces a new value,
-- switch xs ys behaves like ys.
--
-- Example:
--
-- -- xs: 1 2 3 4 5 6 7 8 9 -- ys: 1 2 3 4 5 6 -- -- switch xs ys: 1 2 3 1 2 4 3 4 5 6 --switch :: Sig a -> O (Sig a) -> Sig a -- | This function is similar to switch, but the (future) second -- signal may depend on the last value of the first signal. switchS :: Stable a => Sig a -> O (a -> Sig a) -> Sig a -- | Variant of switchS that repeatedly switches. The output signal -- switch xs ys first behaves like xs, but whenever -- ys produces a value f, the signal switches to f -- v where v is the previous value of the output signal. -- -- switchS can be considered a special case of switchR that -- only makes a single switch. That is we have the following: -- --
-- switchS xs ys = switchR (delay (const (adv xs))) ys --switchR :: Stable a => Sig a -> O (Sig (a -> Sig a)) -> Sig a -- | This function is a variant of zipWith. Whereas zipWith f xs -- ys produces a new value whenever xs or ys -- produce a new value, trigger f xs ys only produces a new -- value when xs produces a new value, otherwise it just repeats the -- previous value. -- -- Example: -- --
-- xs: 1 0 5 2 -- ys: 1 2 3 2 -- -- zipWith (box (+)) xs ys: 2 3 4 3 8 4 -- trigger (box (+)) xy ys: 2 2 2 3 8 4 --trigger :: (Stable b, Stable c) => Box (a -> b -> c) -> Sig a -> Sig b -> Sig c -- | This function is a variant of trigger that works on a delayed -- input signal. To this end, triggerAwait takes an additional -- argument that is the initial value of output signal. -- -- Example: -- --
-- xs: 1 0 5 2 -- ys: 5 1 2 3 2 -- -- triggerAwait (box (+)) 0 xy ys: 0 2 2 2 3 8 4 --triggerAwait :: (Stable b, Stable c) => Box (a -> b -> c) -> c -> O (Sig a) -> Sig b -> Sig c -- | This function is a variant of trigger that only produces a -- value when the first signal ticks; otherwise it produces -- Nothing'. -- -- Example: -- --
-- xs: 1 0 5 2 -- ys: 1 2 3 2 -- -- zipWith (box plus) xs ys: 2 3 4 3 8 4 -- trigger (box plus) xy ys: 2 N N 3 8 4 ---- -- where > plus x y = Just' (x+y) triggerM :: Stable b => Box (a -> b -> Maybe' c) -> Sig a -> Sig b -> Sig (Maybe' c) -- | This function is a variant of triggerAwait that only produces a -- value when the first signal ticks; otherwise it produces -- Nothing'. -- -- Example: -- --
-- xs: 1 0 5 2 -- ys: 5 1 2 3 2 -- -- triggerAwaitM (box plus) xy ys: 2 N N 3 8 4 where plus x y = ---- -- Just' (x+y) triggerAwaitM :: Stable b => Box (a -> b -> Maybe' c) -> O (Sig a) -> Sig b -> O (Sig (Maybe' c)) buffer :: Stable a => a -> Sig a -> Sig a bufferAwait :: Stable a => a -> O (Sig a) -> O (Sig a) -- | This function is similar to switch but works on delayed signals -- instead of signals. switchAwait :: O (Sig a) -> O (Sig a) -> O (Sig a) -- | This function interleaves two signals producing a new value v -- whenever either input stream produces a new value v. In case -- the input signals produce a new value simultaneously, the function -- argument is used break ties, i.e. to compute the new output value -- based on the two new input values -- -- Example: -- --
-- xs: 1 3 5 3 1 3 -- ys: 0 2 4 -- -- interleave (box (+)) xs ys: 1 3 2 5 7 1 3 --interleave :: Box (a -> a -> a) -> O (Sig a) -> O (Sig a) -> O (Sig a) -- | This is the composition of mapAwait and interleave. That -- is, -- --
-- mapInterleave f g xs ys = mapAwait f (interleave xs ys) --mapInterleave :: Box (a -> a) -> Box (a -> a -> a) -> O (Sig a) -> O (Sig a) -> O (Sig a) interleaveAll :: Box (a -> a -> a) -> List (O (Sig a)) -> O (Sig a) -- | Turns a boxed delayed computation into a delayed signal. mkSig :: Box (O a) -> O (Sig a) -- | Variant of mkSig that returns a boxed delayed signal mkBoxSig :: Box (O a) -> Box (O (Sig a)) -- | Get the current value of a signal. current :: Sig a -> a -- | Get the future the signal. future :: Sig a -> O (Sig a) -- | Construct a constant signal that never updates. const :: a -> Sig a -- | jump (box f) xs first behaves like xs, but as soon -- as f x = Just xs' for a (current or future) value x -- of xs, it behaves like xs'. jump :: Box (a -> Maybe' (Sig a)) -> Sig a -> Sig a -- | Similar to jump, but it can jump repeatedly. That is, -- jumping (box f) xs first behaves like xs, but every -- time f x = Just xs' for a (current or future) value -- x of jumping (box f) xs, it behaves like -- xs'. jumping :: Box (a -> Maybe' (Sig a)) -> Sig a -> Sig a -- | Stops as soon as the the predicate becomes true for the current value. -- That is, stop (box p) xs first behaves as xs, but as -- soon as f x = True for some (current or future) value -- x of xs, then it behaves as const x. stop :: Box (a -> Bool) -> Sig a -> Sig a -- | Similar to Haskell's scanl. -- --
-- scan (box f) x (v1 ::: v2 ::: v3 ::: ... ) == (x `f` v1) ::: ((x `f` v1) `f` v2) ::: ... ---- -- Note: Unlike scanl, scan starts with x f -- v1, not x. scan :: Stable b => Box (b -> a -> b) -> b -> Sig a -> Sig b -- | A variant of scan that works with the C monad. scanC :: Stable b => Box (b -> a -> C b) -> b -> Sig a -> C (Sig b) -- | Like scan, but uses a delayed signal. scanAwait :: Stable b => Box (b -> a -> b) -> b -> O (Sig a) -> Sig b -- | A variant of scanAwait that works with the C monad. scanAwaitC :: Stable b => Box (b -> a -> C b) -> b -> O (Sig a) -> C (Sig b) -- | scanMap is a composition of map and scan: -- --
-- scanMap f g x === map g . scan f x --scanMap :: Stable b => Box (b -> a -> b) -> Box (b -> c) -> b -> Sig a -> Sig c -- | Sig a is a stream of values of type a. data Sig a (:::) :: !a -> !O (Sig a) -> Sig a infixr 5 ::: -- | This function is a variant of combines the values of two signals using -- the function argument. zipWith f xs ys produces a new value -- unbox f x y whenever xs or ys produce a new -- value, where x and y are the current values of -- xs and ys, respectively. -- -- Example: -- --
-- xs: 1 2 3 2 -- ys: 1 0 5 2 -- -- zipWith (box (+)) xs ys: 2 3 4 3 8 4 --zipWith :: (Stable a, Stable b) => Box (a -> b -> c) -> Sig a -> Sig b -> Sig c -- | Variant of zipWith with three signals. zipWith3 :: forall a b c d. (Stable a, Stable b, Stable c) => Box (a -> b -> c -> d) -> Sig a -> Sig b -> Sig c -> Sig d -- | This is a special case of zipWith using the tupling function. -- That is, -- --
-- zip = zipWith (box (:*)) --zip :: (Stable a, Stable b) => Sig a -> Sig b -> Sig (a :* b) -- | If-then-else lifted to signals. cond bs xs ys produces a -- stream whose value is taken from xs whenever bs is -- true and from ys otherwise. cond :: Stable a => Sig Bool -> Sig a -> Sig a -> Sig a -- | Takes two signals and updates the first signal using the functions -- produced by the second signal: -- -- Law: -- --
-- (xs `update` fs) `update` gs = (xs `update` (interleave (box (.)) gs fs)) --update :: Stable a => Sig a -> O (Sig (a -> a)) -> Sig a -- | integral x xs computes the integral of the signal xs -- with the constant x. For example, if xs is the -- velocity of an object, the signal integral 0 xs describes the -- distance travelled by that object. integral :: forall a v. (VectorSpace v a, Eq v, Fractional a, Stable v, Stable a) => v -> Sig v -> Sig v -- | Compute the derivative of a signal. For example, if xs is the -- velocity of an object, the signal derivative xs describes the -- acceleration travelled by that object. derivative :: forall a v. (VectorSpace v a, Eq v, Fractional a, Stable v, Stable a) => Sig v -> Sig v instance WidgetRattus.Channels.Producer (WidgetRattus.Signal.SigMaybe a) a instance WidgetRattus.Channels.Producer (WidgetRattus.Signal.Sig a) a instance WidgetRattus.InternalPrimitives.Continuous a => WidgetRattus.InternalPrimitives.Continuous (WidgetRattus.Signal.Sig a) -- | Programming with futures. module WidgetRattus.Future -- | F a will produces a value of type a after zero or -- more ticks of some clocks data F a Now :: !a -> F a Wait :: !O (F a) -> F a -- | SigF a is a signal of values of type a. In contrast -- to Sig, SigF supports the filter and -- filterMap functions. data SigF a (:>:) :: !a -> !O (F (SigF a)) -> SigF a mkSigF :: Box (O a) -> F (SigF a) mkSigF' :: Box (O a) -> O (F (SigF a)) -- | Get the current value of a signal. current :: SigF a -> a -- | Get the future the signal. future :: SigF a -> O (F (SigF a)) bindF :: F a -> Box (a -> F b) -> F b mapF :: Box (a -> b) -> F a -> F b sync :: O (F a) -> O (F b) -> O (F a :* F b) syncF :: (Stable a, Stable b) => F a -> F b -> F (a :* b) switchAwait :: F (SigF a) -> F (SigF a) -> F (SigF a) switch :: SigF a -> F (SigF a) -> SigF a switchS :: Stable a => SigF a -> F (a -> SigF a) -> SigF a filterMap :: Box (a -> Maybe' b) -> SigF a -> F (SigF b) filterMapAwait :: Box (a -> Maybe' b) -> F (SigF a) -> F (SigF b) filterAwait :: Box (a -> Bool) -> F (SigF a) -> F (SigF a) filter :: Box (a -> Bool) -> SigF a -> F (SigF a) trigger :: Stable b => Box (a -> b -> c) -> SigF a -> SigF b -> SigF c triggerAwait :: Stable b => Box (a -> b -> c) -> F (SigF a) -> SigF b -> F (SigF c) map :: Box (a -> b) -> SigF a -> SigF b mapAwait :: Box (a -> b) -> F (SigF a) -> F (SigF b) zipWith :: (Stable a, Stable b) => Box (a -> b -> c) -> SigF a -> SigF b -> SigF c zipWithAwait :: (Stable a, Stable b) => Box (a -> b -> c) -> a -> b -> F (SigF a) -> F (SigF b) -> F (SigF c) fromSig :: Sig a -> SigF a scan :: Stable b => Box (b -> a -> b) -> b -> SigF a -> SigF b scanAwait :: Stable b => Box (b -> a -> b) -> b -> F (SigF a) -> F (SigF b) instance WidgetRattus.Channels.Producer (WidgetRattus.Future.SigF a) a instance WidgetRattus.Channels.Producer (WidgetRattus.Future.OneShot a) a instance WidgetRattus.Channels.Producer p a => WidgetRattus.Channels.Producer (WidgetRattus.Future.F p) a module WidgetRattus.Widgets class Stable a => Displayable a display :: Displayable a => a -> Text class Continuous a => IsWidget a mkWidgetNode :: IsWidget a => a -> WidgetNode AppModel AppEvent mkWidget :: IsWidget a => a -> Widget setEnabled :: IsWidget a => a -> Sig Bool -> Widget class Widgets ws toWidgetList :: Widgets ws => ws -> List Widget data Widget data HStack data VStack data TextDropdown tddCurr :: TextDropdown -> Sig Text tddEvent :: TextDropdown -> Chan Text tddList :: TextDropdown -> Sig (List Text) data Popup popCurr :: Popup -> Sig Bool popEvent :: Popup -> Chan Bool popChild :: Popup -> Sig Widget data Slider sldCurr :: Slider -> Sig Int sldEvent :: Slider -> Chan Int sldMin :: Slider -> Sig Int sldMax :: Slider -> Sig Int data Button btnContent :: Button -> Sig a btnClick :: Button -> Chan () data Label labText :: Label -> Sig a data TextField tfContent :: TextField -> Sig Text tfInput :: TextField -> Chan Text mkButton :: Displayable a => Sig a -> C Button mkTextField :: Text -> C TextField addInputSigTF :: TextField -> O (Sig Text) -> TextField mkLabel :: Displayable a => Sig a -> C Label mkHStack :: IsWidget a => Sig (List a) -> C HStack mkConstHStack :: Widgets ws => ws -> C HStack mkVStack :: IsWidget a => Sig (List a) -> C VStack mkConstVStack :: Widgets ws => ws -> C VStack mkTextDropdown :: Sig (List Text) -> Text -> C TextDropdown mkPopup :: Sig Bool -> Sig Widget -> C Popup mkSlider :: Int -> Sig Int -> Sig Int -> C Slider mkProgressBar :: Sig Int -> Sig Int -> Sig Int -> C Slider btnOnClick :: Button -> Box (O ()) btnOnClickSig :: Button -> O (Sig ()) setInputSigTF :: TextField -> Sig Text -> TextField textFieldOnInput :: TextField -> Box (O Text) textFieldOnInputSig :: TextField -> O (Sig Text) runApplication :: IsWidget a => C a -> IO () instance WidgetRattus.Widgets.InternalTypes.IsWidget w => WidgetRattus.Widgets.Widgets w instance (WidgetRattus.Widgets.Widgets w, WidgetRattus.Widgets.Widgets v) => WidgetRattus.Widgets.Widgets (w WidgetRattus.Strict.:* v) instance WidgetRattus.Widgets.Widgets w => WidgetRattus.Widgets.Widgets (WidgetRattus.Strict.List w) instance WidgetRattus.Widgets.InternalTypes.Displayable Data.Text.Internal.Text instance WidgetRattus.Widgets.InternalTypes.Displayable GHC.Types.Int