Skip to content
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.

Certain record type signatures changes should be a minor update. #256

Closed
AnthonyJacob opened this issue Dec 11, 2016 · 7 comments
Closed

Comments

@AnthonyJacob
Copy link

AnthonyJacob commented Dec 11, 2016

Currently if you change foo : {a | x : Int} to foo : {a | x : Int, y : Int} it will be considered as major change, because you changed the type signature. Or did you?

Generic record signatures ( {a | ... } ) are weak toward field deletion! That means you can change {x = 2} to {} anywhere just by changing its signature. That is significant for library authors, because they can make non-breaking changes, even though they can look like breaking one.

For whatever reason {a | } is not valid type...

Few examples:

{a | x:Int} ==> {b | x:Int, y:Int}
{a | x:Int, y:Int} =/=> {b | x:Int}

{a | x:Int, y:Int} -> _ ==> {b | x:Int} -> _
{a | x:Int} -> _ =/=> {b | x:Int, y:Int} -> _

({a | x:Int} -> {a | x:Int}) -> _ ==> ({b | x:Int, y:Int} -> {b | x:Int, y:Int}) -> _
({a | x:Int, y:Int} -> {a | x:Int, y:Int}) -> _ =/=> ({b | x:Int} -> {b | x:Int}) -> _

Explanation:

==> first signature implies the second one (side effect : changing first to second won't break anybody's code)
=/=> first signature does not imply the second one (side effect : changing first to second will break the users code)

You can think of it as type alias that works only in one way.

@process-bot
Copy link

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@AnthonyJacob AnthonyJacob changed the title Addition of field to record should a minor update. Certain record type signatures changes should a minor update. Dec 11, 2016
@JoeyEremondi
Copy link
Contributor

JoeyEremondi commented Dec 11, 2016 via email

@jvoigtlaender
Copy link
Contributor

Actually, the assertions in the original comment here are wrong. It's not true that by changing foo : {} to foo : {x : Int} you won't break anybody's code.

If somebody has this in their code:

import Package exposing (foo)

f : {} -> Int
f _ = 42

e = f foo

then as long as Package has foo : {}, that somebody's code will compile, but as soon as Package switches to foo : {x : Int}, that somebody's code will not compile anymore.

@AnthonyJacob, I think you have a wrong understanding of how record type annotations work.

@AnthonyJacob AnthonyJacob changed the title Certain record type signatures changes should a minor update. Certain record type signatures changes should be a minor update. Dec 11, 2016
@AnthonyJacob
Copy link
Author

AnthonyJacob commented Dec 11, 2016

@jvoigtlaender Oops, seems like I have overlooked something.

Never mind though, it is still possible if you use{a | ...} instead.

@jvoigtlaender
Copy link
Contributor

Your examples are still wrong, though. Because you use the same type variable (a) on both sides. Your assertion about what ==> means in those cases is simply not true.

I suggest you close the issue here and instead start a topic on the mailing list to come to a full understanding and proposal.

@AnthonyJacob
Copy link
Author

I didn't expect somebody is going to read it as forall a. ... ==> ... instead of forall a. ... ==> forall a. .... Never mind.

What mailing list do you have on mind?

@jvoigtlaender
Copy link
Contributor

The thing you dismiss as "Never mind" is not the real problem with your examples I meant.

As for discussion forum, see http://elm-lang.org/community. (And what process-bot's links have already pointed out about what the role of this issue tracker here is and is not.)

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

No branches or pull requests

4 participants