[Haskell-cafe] Applicative of Applicative

martin martin.drautzburg at web.de
Tue Mar 24 19:07:00 UTC 2015


Am 03/24/2015 um 06:40 PM schrieb Tikhon Jelvis:

> As far as time-varying code goes, you were right in your intuition that it's closely related to FRP. You have, in fact,
> come up with a type similar to events in classical FRP—an accomplishment on its own! 


My temporal type is defined as follows

data Change a = Chg {
            ct :: Time, -- "change time"
            cv :: a     -- "change value"
}

data Temporal a = Temporal {
    td :: a,         -- "temporal default"
    tc :: [Change a] -- "temporal changes"
} deriving (Show)

I started off with "Event" instead of "Change", but found this misleading. Two successive changes with the same value
have the same effect as a single change, while for Events in the sense of "left button click" there is a difference
between a click and a doubleclick.

I don't know if I'll ever have to intersperse Changes from two lists. In that case two successive changes to the same
value *will* make a difference, because the second change my undo the effect of an interspersed change.

I am still somewhat struggeling with train schedules. I'd love to craft an example with a summer and a winter schedule,
but I don't quite know what to use as a value. Intuitively it'd be something like "departure time", but of what? I am
not sure if there is a missing piece, or if I just have to turn away from traditional train schedules and us "train on
track 1" as the changing value.


More information about the Haskell-Cafe mailing list