Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upMake `Set a` and `Dict a ()` be different types? #260
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jun 4, 2015
Contributor
BTW, I conjecture Set a and Dict a () are currently only accidentally not distinguished, similarly as in #234, where Evan indicated that at same point in the past it wasn't clear whether type aliases (which are at play here) would behave like Haskell's type or like Haskell's newtype.
|
BTW, I conjecture |
jvoigtlaender
referenced this issue
Jun 5, 2015
Merged
Make `Set t` a type different from `Dict t ()` #263
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Closed via https://github.com/elm-lang/core/pull/263. |
jvoigtlaender
closed this
Jun 30, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Jun 30, 2015
Member
Oh, also, this means that the toString function is messed up for now. We may want to give the internal constructor a weirder name when we fix that!
|
Oh, also, this means that the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jul 1, 2015
Contributor
So currently it will say something like Set (Dict.fromList [(0,())]) instead of Set.fromList [0]? Well, probably better to fix that, yes. Though I must say looking at the implementation of toString in the native JS code right now, I'm a bit scared overall. I mean, it seems that if somebody decided to have a constructor named RBNode in their own union type, results could be quite catastrophic?
|
So currently it will say something like |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jul 1, 2015
Contributor
Indeed, this leads to a runtime error:
import Graphics.Element
type V = RBNode
v = RBNode
main = Graphics.Element.show v|
Indeed, this leads to a runtime error: import Graphics.Element
type V = RBNode
v = RBNode
main = Graphics.Element.show v |
jvoigtlaender commentedJun 4, 2015
Currently they are not. Which means that expressions like
Dict.get 5 (Set.singleton 7)etc. are type-correct, even though:Setdoes not itself have agetfunction)Dict.getandSet.singletonare completely incompatible, as far as a reader of http://package.elm-lang.org/packages/elm-lang/core/latest/Dict and http://package.elm-lang.org/packages/elm-lang/core/latest/Set is concerned).