mapF
and mapstateF
for this:
facF = intDispF >==< mapF fac >==< intInputF
The functionscounterF = intDispF >==< mapstateF count 0 >==< buttonF "Up"
mapF
and mapstateF
create abstract
fudgets, that is, fudgets that do not perform any I/O. They
communicate only via their high-level streams.
A more general way to construct abstract fudgets is provided by
the function absF
,
whereabsF :: SP a b -> F a b
SP
is the type constructor for plain stream
processors. These have a single input stream and a single output
stream. The function absF
creates a fudget by connecting
the streams of a stream processor to the high-level streams of the
fudgets, while leaving the low-level streams disconnected, as
shown in Figure 21.
Figure 21. Turning a stream processor into an abstract fudget.
The functions mapF
and mapstateF
are in fact
defined in terms of absF
:
wheremapF = absF mapSP mapstateF = absF mapstateSP
mapSP
and mapstateSP
,
are discussed in Section 16.2 and Section 16.3, respectively.mapSP :: (a -> b) -> SP a b mapstateSP :: (a -> b -> (a, [c])) -> a -> SP b c
Although high-level combinators like mapF
and mapstateF
are adequate for most fudget application programming,
some programmers may prefer the flexibility of the more basic ways
of creating stream processors. Two examples where abstract fudgets
are defined in terms of absF
can be found in
Section 32.4. An extensive discussion of stream processors can
be found in Part III.