auto-0.4.3.1: Denotative, locally stateful programming DSL & platform

Control.Auto.Blip.Internal

Description

This module exposes an "unsafe" interface for working with the internal representation of "blip streams". If you are programming at the logic level or the application level, you should thoroughly be able to avoid importing this, and should be happy with importing the Blip type from Control.Auto and blip stream manipulators from Control.Auto.Blip.

If, however, you are programming a framework, library, or backend, you might find it useful to manually create your own blip streams/sources. In this case, this module will be useful.

It is important, as with most of this library in general, to always keep in mind when you are programming at the "logic" level, and when you are programming at the "backend" level. If you can justify that you are at the backend level and not at the logic level of whatever you are programming, then this is useful.

Be sure, of course, that whatever blip streams you do manually construct and export preserve "Blip semantics", which is further defined in Control.Auto.Blip.

You have been warned!

Synopsis

# Documentation

data Blip a Source #

When used in the context of an input or output of an Auto, a Blip a represents a stream that occasionally, at "independent" or "discrete" points, emits a value of type a.

Contrast this to Interval, where things are meant to be "on" or "off" for contiguous chunks at a time; blip streams are "blippy", and Intervals are "chunky".

It's here mainly because it's a pretty useful abstraction in the context of the many combinators found in various modules of this library. If you think of an Auto m a (Blip b) as producing a "blip stream", then there are various combinators and functions that are specifically designed to manipulate blip streams.

For the purposes of the semantics of what Blip is supposed to represent, its constructors are hidden. (Almost) all of the various Blip combinators (and its very useful Functor instance) "preserve Blipness" --- one-at-a-time occurrences remain one-at-a-time under all of these combinators, and you should have enough so that direct access to the constructor is not needed.

If you are creating a framework, library, or backend, you might want to manually create blip stream-producing Autos for your users to access. In this case, you can import the constructors and useful internal (and, of course, semantically unsafe) functions from Control.Auto.Blip.Internal.

Constructors

 NoBlip Blip !a

Instances

 Source # Methodsfmap :: (a -> b) -> Blip a -> Blip b #(<\$) :: a -> Blip b -> Blip a # Show a => Show (Blip a) Source # MethodsshowsPrec :: Int -> Blip a -> ShowS #show :: Blip a -> String #showList :: [Blip a] -> ShowS # Generic (Blip a) Source # Associated Typestype Rep (Blip a) :: * -> * # Methodsfrom :: Blip a -> Rep (Blip a) x #to :: Rep (Blip a) x -> Blip a # Semigroup a => Semigroup (Blip a) Source # Merge two blip streams together; the result emits with either of the two merged streams emit. When both emit at the same time, emit the result of <>-ing the values together. Methods(<>) :: Blip a -> Blip a -> Blip a #sconcat :: NonEmpty (Blip a) -> Blip a #stimes :: Integral b => b -> Blip a -> Blip a # Semigroup a => Monoid (Blip a) Source # Merge two blip streams together; the result emits with either of the two merged streams emit. When both emit at the same time, emit the result of <>-ing the values together. Methodsmempty :: Blip a #mappend :: Blip a -> Blip a -> Blip a #mconcat :: [Blip a] -> Blip a # Serialize a => Serialize (Blip a) Source # Methodsput :: Putter (Blip a) #get :: Get (Blip a) # NFData a => NFData (Blip a) Source # Methodsrnf :: Blip a -> () # type Rep (Blip a) Source # type Rep (Blip a) = D1 (MetaData "Blip" "Control.Auto.Blip.Internal" "auto-0.4.3.1-HNJqqybobBbJ06ezEJkkhZ" False) ((:+:) (C1 (MetaCons "NoBlip" PrefixI False) U1) (C1 (MetaCons "Blip" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a))))

Arguments

 :: (a -> a -> a) merging function -> Blip a first stream -> Blip a second stream -> Blip a merged stream

Merge two blip streams together; the result emits with either of the two merged streams emit. When both emit at the same time, emit the result of applying the given function on the two emitted values.

Note that this might be too strict for some purposes; see mergeL and mergeR for lazier alternatives.

Arguments

 :: (a -> c) function for first stream -> (b -> c) function for second stream -> (a -> b -> c) merging function -> Blip a first stream -> Blip b second stream -> Blip c merged stream

Slightly more powerful merge, but I can't imagine a situation where this power is necessary.

If only the first stream emits, emit with the first function applied to the value. If only the second stream emits, emit with the second function applied to the value. If both emit, then emit with the third function applied to both emitted values.

mergeL infixr 5 Source #

Arguments

 :: Blip a first stream (higher priority) -> Blip a second stream -> Blip a

Merges two blip streams together into one, which emits either of the original blip streams emit. If both emit at the same time, the left (first) one is favored.

Lazy on the second stream if the first stream is emitting.

If we discount laziness, this is merge const.

mergeR infixl 5 Source #

Arguments

 :: Blip a first stream -> Blip a second stream (higher priority) -> Blip a

Merges two blip streams together into one, which emits either of the original blip streams emit. If both emit at the same time, the right (second) one is favored.

Lazy on the first stream if the second stream is emitting.

If we discount laziness, this is merge (flip const).

Arguments

 :: b default value -> (a -> b) function to apply on value -> Blip a Blip to deconstruct -> b

Deconstruct a Blip by giving a default result if the Blip is non-occuring and a function to apply on the contents, if the Blip is occuring.

Try not to use if possible, unless you are a framework developer. If you're just making an application, try to use the other various combinators in this library. It'll help you preserve the semantics of what it means to be Blippy.

Analogous to maybe from Prelude.