We have made the previous Factorial function example more self documenting by adding labels to the entry field and the output display. We have also changed the order of the two parts: the entry field is now above the display.
Here is the source code:
import Fudgets main = fudlogue (shellF "Fac" facF) facF = placerF (revP verticalP) ( ("x! =" `labLeftOfF` intDispF) >==< mapF fac >==< ("x =" `labLeftOfF` intInputF)) fac 0 = 1 fac n = n * fac (n-1)
labLeftOfFto put labels to the left of the entry field and the display. (In Haskell, back quotes can be used to turn any function into an infix operator, as we have done with
placerFcan be applied to a composition of fudgets to specify the relative placement of the parts. (The layout system automatically picks some placement if you don't specify it yourself.) The first argument to
placerFis a placer, in our case
revP verticalP, where
verticalPcauses the parts to be stacked vertically with the leftmost fudget in the composition at the top, and
revPreverses the order of the parts.