Program a b
is a pure representation of a computer program,
which accepts inputs of type a
, and outputs values of type b
.
It may also terminate. It can output zero or more b
values after each a
input.
 A simple stateless inputoutputloop can be created from a function
with
arrC
.  A simple stateful inputoutputloop can be created using
scanlP
.  Outputs can be filtered using
filterC
.
Programs may also be composed together in several ways using common typeclasses

Category
:Program a b > Program b c > Program a c
. One program's outputs are fed to another program as input. 
Monoid
:Program a b > Program a b > Program a b
. Both programs run in parallel processing the same input. Resulting Program outputs both's outputs. 
Applicative
:Program a (b > c) > Program a b > Program a c
.  Alternative
MonadPlus
:AppendProgram
is a newtype wrapper whoseMonoid
instance runs one program after the other finishes (likeZipList
offers an alternativeApplicative
instance for lists). It's also aMonad
ant its monadic bind allows us to invoke inner programs based on an outer program's outputs.
 data Program a b = Program {}
 newtype AppendProgram a b = AppendProg {
 runAppendProg :: Program a b
 scanlP :: (b > a > b) > b > Program a b
 emptyP :: Program a b
 takeWhileP :: (a > Bool) > Program a a
 loopbackP :: Program a (Either a b) > Program a b
 singleValueP :: Program a ()
 lstP :: (a > Maybe b) > Program a b
 lstPs :: Maybe b > (a > Maybe b) > Program a b
 delayP :: Integral i => i > Program a a
 withAppendProgram1 :: forall a0 b0 a1 b1. (AppendProgram a0 b0 > AppendProgram a1 b1) > Program a0 b0 > Program a1 b1
 withAppendProgram2 :: forall a0 b0 a1 b1 a2 b2. (AppendProgram a0 b0 > AppendProgram a1 b1 > AppendProgram a2 b2) > Program a0 b0 > Program a1 b1 > Program a2 b2
Documentation
A computer program
Category Program  
FilterCategory Program  
Functor (Program t1)  
Applicative (Program a)  
Monoid (Program a b) 
newtype AppendProgram a b Source
AppendProg  

scanlP :: (b > a > b) > b > Program a bSource
Create a stateful inputoutputloop from a simple function
takeWhileP :: (a > Bool) > Program a aSource
Terminate when a predicate on input fails
singleValueP :: Program a ()Source
A program that outputs a value and immediately terminates
lstP :: (a > Maybe b) > Program a bSource
Given a partial function (a > Maybe b)
, output its most recent result on an input.
lstPs :: Maybe b > (a > Maybe b) > Program a bSource
Given a partial function (a > Maybe b)
and a start value, output its most recent result on an input.
withAppendProgram1 :: forall a0 b0 a1 b1. (AppendProgram a0 b0 > AppendProgram a1 b1) > Program a0 b0 > Program a1 b1Source
withAppendProgram2 :: forall a0 b0 a1 b1 a2 b2. (AppendProgram a0 b0 > AppendProgram a1 b1 > AppendProgram a2 b2) > Program a0 b0 > Program a1 b1 > Program a2 b2Source