Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Posix to flow through ports #6

Open
elliotdickison opened this issue Sep 2, 2018 · 0 comments
Open

Allow Posix to flow through ports #6

elliotdickison opened this issue Sep 2, 2018 · 0 comments

Comments

@elliotdickison
Copy link

TL;DR

Would it be possible to make Posix a type that could flow freely over ports?

Background

I'm in the progress of upgrading a project from 0.18 to 0.19 (new release looks great, thanks!) and ran into a slight hiccup with the new Posix type. Unlike the old Time type which was just an alias for Float, the new Posix type is opaque so I can't use it interchangeably with it's basic type (now Int in 0.19). I actually like that this forces me to use Posix consistently everywhere.

The issue is that I used to send a lot of records containing timestamps over ports. In 0.18 this worked seamlessly with time values being treated as Floats, but now I get errors like the following one:

The `user` port is trying to transmit a `Posix` value:

87| port user : User -> Cmd msg
         ^^^^^^^^^^^^
I cannot handle that. The types that CAN flow in and out of Elm include:

    Ints, Floats, Bools, Strings, Maybes, Lists, Arrays, tuples, records, and
    JSON values.

Given that Posix is really just an Int (and is unlikely to ever change given the nature of that data) it seems a shame to have to create a new record type and manually covert Posix to Int before sending the data over the port. Would it be possible to make Posix a type that could flow freely over ports? I don't know how much work that involves and I'm not sure if there might be unintended consequences to this proposal, but I wanted to throw it out there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant