copilot-frp-sketch-1.0.0: FRP sketch programming with Copilot
Safe HaskellNone
LanguageHaskell2010

Copilot.FRPSketch

Synopsis

Documentation

blinking :: Behavior Bool Source #

Use this to make a LED blink on and off.

On each iteration of the Sketch, this changes to the opposite of its previous value.

This is implemented using Copilot's clk, so to get other blinking behaviors, just pick different numbers, or use Copilot Stream combinators.

blinking = clk (period 2) (phase 1)

firstIteration :: Behavior Bool Source #

True on the first iteration of the Sketch, and False thereafter.

frequency :: Integer -> Behavior Bool Source #

Use this to make an event occur 1 time out of n.

This is implemented using Copilot's clk:

frequency = clk (period n) (phase 1)

data MilliSeconds Source #

A stream of milliseconds.

Constructors

MilliSeconds (Stream Word32) 

data MicroSeconds Source #

A stream of microseconds.

Constructors

MicroSeconds (Stream Word32) 

delay :: Delay Source #

Use this to add a delay between each iteration of the Sketch. A Sketch with no delay will run as fast as the hardware can run it.

delay := MilliSeconds (constant 100)

data Delay Source #

Constructors

Delay 

class IfThenElse t a where Source #

Methods

ifThenElse :: Behavior Bool -> t a -> t a -> t a Source #

This allows "if then else" expressions to be written that choose between two Streams, or Behaviors, or TypedBehaviors, or Sketches, when the RebindableSyntax language extension is enabled.

{-# LANGUAGE RebindableSyntax #-}
buttonpressed <- input pin3
if buttonpressed then ... else ...

Instances

Instances details
Typed a => IfThenElse Stream a Source # 
Instance details

Defined in Copilot.FRPSketch

Methods

ifThenElse :: Behavior Bool -> Stream a -> Stream a -> Stream a Source #

Ord pinid => IfThenElse (GenSketch pinid) () Source # 
Instance details

Defined in Copilot.FRPSketch

Methods

ifThenElse :: Behavior Bool -> GenSketch pinid () -> GenSketch pinid () -> GenSketch pinid () Source #

(Ord pinid, Typed a) => IfThenElse (GenSketch pinid) (Behavior a) Source # 
Instance details

Defined in Copilot.FRPSketch

Methods

ifThenElse :: Behavior Bool -> GenSketch pinid (Behavior a) -> GenSketch pinid (Behavior a) -> GenSketch pinid (Behavior a) Source #

Typed a => IfThenElse (TypedBehavior p) a Source # 
Instance details

Defined in Copilot.FRPSketch

scheduleB :: (Typed t, Eq t, Ord pinid) => Behavior t -> [(t, GenSketch pinid ())] -> GenSketch pinid () Source #

Schedule when to perform different Sketches.

sketchSpec :: Ord pinid => GenSketch pinid a -> Spec Source #

Extracts a copilot Spec from a Sketch.

This can be useful to intergrate with other libraries such as copilot-theorem.

liftB :: (Behavior a -> Behavior r) -> TypedBehavior t a -> Behavior r Source #

Apply a Copilot DSL function to a TypedBehavior.

liftB2 :: (Behavior a -> Behavior b -> Behavior r) -> TypedBehavior t a -> TypedBehavior t b -> Behavior r Source #

Apply a Copilot DSL function to two TypedBehaviors.