[Haskell-cafe] Applicative of Applicative

M Farkas-Dyck strake888 at gmail.com
Tue Mar 24 21:26:00 UTC 2015

On 24/03/2015 at 20:07:00 +0100, martin wrote:
> 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.

As you have it, yes. One could alternately define

data Change a = Chg { ct :: Time, c :: a -> a }

in which case changes would not in general be idempotent, and idempotent changes would have form Chg { ct = _, c = pure _ }.

> 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.

Seems a good reason to keep multiplicates in the list ☺

> 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.

Each train could have a Temporal Location.

Which definition makes sense is a function of what you want to ask of the schedules.

More information about the Haskell-Cafe mailing list