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

Make `Set a` and `Dict a ()` be different types? #260

Closed
jvoigtlaender opened this Issue Jun 4, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@jvoigtlaender
Contributor

jvoigtlaender commented Jun 4, 2015

Currently they are not. Which means that expressions like Dict.get 5 (Set.singleton 7) etc. are type-correct, even though:

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

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.

Contributor

jvoigtlaender commented Jun 4, 2015

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.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
Contributor

jvoigtlaender commented Jun 30, 2015

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

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!

Member

evancz commented Jun 30, 2015

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!

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

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?

Contributor

jvoigtlaender commented Jul 1, 2015

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?

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

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
Contributor

jvoigtlaender commented Jul 1, 2015

Indeed, this leads to a runtime error:

import Graphics.Element

type V = RBNode

v = RBNode

main = Graphics.Element.show v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment