arduino-copilot-1.0.1: Arduino programming in haskell using the Copilot stream DSL

Safe HaskellNone
LanguageHaskell98

Copilot.Arduino.Internals

Description

You should not need to import this module unless you're adding support for a new model of Arduino, or an Arduino library.

Synopsis

Documentation

newtype Sketch t Source #

An Arduino sketch, implemented using Copilot.

It's best to think of the Sketch as a description of the state of the Arduino at any point in time.

Under the hood, the Sketch is run in a loop. On each iteration, it first reads all inputs and then updates outputs as needed. While it is a monad, a Sketch's outputs are not updated in any particular order, because Copilot does not guarantee any order.

Constructors

Sketch (Writer [(Spec, Framework)] t) 
Instances
Monad Sketch Source # 
Instance details

Defined in Copilot.Arduino.Internals

Methods

(>>=) :: Sketch a -> (a -> Sketch b) -> Sketch b #

(>>) :: Sketch a -> Sketch b -> Sketch b #

return :: a -> Sketch a #

fail :: String -> Sketch a #

Functor Sketch Source # 
Instance details

Defined in Copilot.Arduino.Internals

Methods

fmap :: (a -> b) -> Sketch a -> Sketch b #

(<$) :: a -> Sketch b -> Sketch a #

Applicative Sketch Source # 
Instance details

Defined in Copilot.Arduino.Internals

Methods

pure :: a -> Sketch a #

(<*>) :: Sketch (a -> b) -> Sketch a -> Sketch b #

liftA2 :: (a -> b -> c) -> Sketch a -> Sketch b -> Sketch c #

(*>) :: Sketch a -> Sketch b -> Sketch b #

(<*) :: Sketch a -> Sketch b -> Sketch a #

Semigroup (Sketch t) Source # 
Instance details

Defined in Copilot.Arduino.Internals

Methods

(<>) :: Sketch t -> Sketch t -> Sketch t #

sconcat :: NonEmpty (Sketch t) -> Sketch t #

stimes :: Integral b => b -> Sketch t -> Sketch t #

Monoid (Sketch ()) Source # 
Instance details

Defined in Copilot.Arduino.Internals

Methods

mempty :: Sketch () #

mappend :: Sketch () -> Sketch () -> Sketch () #

mconcat :: [Sketch ()] -> Sketch () #

MonadWriter [(Spec, Framework)] Sketch Source # 
Instance details

Defined in Copilot.Arduino.Internals

Methods

writer :: (a, [(Spec, Framework)]) -> Sketch a #

tell :: [(Spec, Framework)] -> Sketch () #

listen :: Sketch a -> Sketch (a, [(Spec, Framework)]) #

pass :: Sketch (a, [(Spec, Framework)] -> [(Spec, Framework)]) -> Sketch a #

data Framework Source #

The framework of an Arduino sketch.

Constructors

Framework 

Fields

Instances
Semigroup Framework Source # 
Instance details

Defined in Copilot.Arduino.Internals

Monoid Framework Source # 
Instance details

Defined in Copilot.Arduino.Internals

MonadWriter [(Spec, Framework)] Sketch Source # 
Instance details

Defined in Copilot.Arduino.Internals

Methods

writer :: (a, [(Spec, Framework)]) -> Sketch a #

tell :: [(Spec, Framework)] -> Sketch () #

listen :: Sketch a -> Sketch (a, [(Spec, Framework)]) #

pass :: Sketch (a, [(Spec, Framework)] -> [(Spec, Framework)]) -> Sketch a #

type CFragment = String Source #

A fragment of C code.

class ToFramework t where Source #

Methods

toFramework :: t -> Framework Source #

Instances
ToFramework (InputSource t) Source # 
Instance details

Defined in Copilot.Arduino.Internals

ToFramework (Output t) Source # 
Instance details

Defined in Copilot.Arduino.Internals

type Behavior t = Stream t -> Spec Source #

data Output t Source #

Somewhere that a Stream can be directed to, in order to control the Arduino.

Constructors

Output 

Fields

Instances
ToFramework (Output t) Source # 
Instance details

Defined in Copilot.Arduino.Internals

type Input t = Sketch (Stream t) Source #

A source of a Stream of values input from the Arduino.

Runs in the Sketch monad.

data InputSource t Source #

Constructors

InputSource 

Fields

Instances
ToFramework (InputSource t) Source # 
Instance details

Defined in Copilot.Arduino.Internals

newtype GPIO Source #

A GPIO pin

For definitions of GPIO pins like pin12, load a module such as Copilot.Arduino.Uno, which provides the pins of a particular board.

Constructors

GPIO Int16 

sketchFramework :: Framework -> [String] -> [CFragment] Source #

Makes an arduino sketch, using a Framework, and a list of lines of C code generated by Copilot.