[Haskell-cafe] Semantics of temporal data

Oleg Grenrus oleg.grenrus at iki.fi
Tue Mar 31 08:27:56 UTC 2015

Your Temporal type looks semantically very similar to FRP’s Behaviour.

Following http://conal.net/papers/push-pull-frp/ <http://conal.net/papers/push-pull-frp/> :

We could specify the time domain as `Maybe Time`, where
- `Nothing` is “before everything - distant past”, needed for “temporal default”,
-  `Just t` are finite values of time

newtype Behaviour a = Behaviour (Maybe Time -> a)

It’s quite straightforward to verify that your Temporal and this Behaviour are isomorphic,
assuming that `Change`s are sorted by time, and there aren’t consecutive duplicates.

I find this “higher-order” formulation easier to reason about, as it’s `(->) Maybe Time`, for which we have
lot’s of machinery already defined (e.g. Monad).

So you could verify direct join implementation on `Temporal` by:

join_prop :: Temporal (Temporal Int) -> Property
join_prop temp = join temporal == fromBehaviour (join (toBehaviour temporal))

One might need to use weaker equality here though.

> On 31 Mar 2015, at 08:14, martin <martin.drautzburg at web.de> wrote:
> Am 03/31/2015 um 02:41 AM schrieb M Farkas-Dyck:
>> On 30/03/2015 at 22:23:17 +0200, martin wrote:
>>> It appears to me that the defaults of the inner Temporal lose most of their meaning. The effective default is the change
>>> value of the last accepted change from the previous (t0) iteration.
>>> Does this make some sense? Please feel free to comment.
>> Yes, as the default value is essentially a change at the lower bound of time, 0 or -∞ or whenever it is, so if we join
>> Temporal x [Change t1 (Temporal y _)]
>> the change to y in the inner Temporal would happen at earliest possible time, so assuming t1 is later than this y ought to be ignored, I think.
> That neatly sums it up (and will make my code more concise). Thanks.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org <mailto:Haskell-Cafe at haskell.org>
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe <http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150331/e8821894/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150331/e8821894/attachment.sig>

More information about the Haskell-Cafe mailing list