[Haskell-cafe] Encoding for flow charts

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Tue Dec 30 16:30:02 UTC 2014

On Tue, Dec 30, 2014 at 04:23:25PM +0000, Tom Ellis wrote:
> On Thu, Dec 25, 2014 at 04:34:19PM -0700, Richard Wallace wrote:
> > I've been working to encode a fairly complex flow chart.
> What precisely do you mean by "flow chart"?
> If you mean something loosely described as "a sequence of nodes which lets
> you perform actions and choose a next path based on the results of those
> actions" then isn't each node just `M Bool` for some monad of appropriate
> actions `M`?

For example here is the flowchart from the top of


implemented as I describe:

    plugInLamp  :: M ()
    replaceBulb :: M ()
    repairLamp  :: M ()

    lampPluggedIn :: M Bool
    bulbBurnedOut :: M Bool

    lampDoesn'tWork :: M ()
    lampDoesn'tWork = do
        p <- lampPluggedIn
        if not p then plugInLamp
        else do
            b <- bulbBurnedOut
            if b then replaceBulb
            else repairLamp

More information about the Haskell-Cafe mailing list