-
Notifications
You must be signed in to change notification settings - Fork 10
Superceded - Update to v0.14.0-rc2 #23
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
Conversation
src/Data/Newtype.purs
Outdated
wrap :: a -> t | ||
unwrap :: t -> a | ||
class Newtype :: Type -> Type -> Constraint | ||
class (Coercible t a, Coercible a t) <= Newtype t a | t -> a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of those Coercible constraints will become redundant when (if?) we merge purescript/purescript#3930.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but until that's done, I'm leaving this in.
I'd like to leave out the Coercible superclasses and the removal of the Newtype class's methods for now, mostly because this change will require additional compiler changes due to the compiler having knowledge of the Newtype class. |
Is this due to not wanting to hold up the v0.14.0 release? |
Yes |
I've added back in the |
CI passes now. |
Can you update psa to 0.8.0 in package.json please? It's still using an older version, which is what's causing the raw JSON output in CI. Also, I'm less sure about this approach - it seems weird to me to use Coercible for half of the conversions, but Newtype for the rest. I'd prefer to spend a bit more time exploring the design space before updating this library to make use of Coercible. Coercible is essentially a more powerful version of Newtype, since it can do everything Newtype can and more, so maybe that raises the question of whether Newtype should continue to exist? For example, we can now write:
The only reasons I can think of that we wouldn't do this is that type inference won't be quite as good since we don't have the functional dependency that the Newtype class has, and also since it's more power than you need in cases where you only want to unwrap one layer of newtypes. Really I think this is a significant enough change that it needs its own PR. |
Good point. I hadn't considered that... Could these functions be ported to |
I think these functions should exist in a separate non-core library first, and we can consider moving them into core after they've been used for a while and we have a better idea of how useful they are. |
I'm not saying we should remove the Newtype class - I think if I had to decide right now I'd actually say we shouldn't remove it. I'm just saying I don't think we've yet explored the design space well enough to make a change like this for a library that so many other libraries depend on. |
Ah, ok. That makes more sense. So, keep this library as it originally was (but updated to v0.14.0) and then explore the design space of this context in a separate non-core repo. Once that gets more mature, migrate that repo into core, correct? |
Yes, exactly. The point of the exploration is to decide what to do next: we won't necessarily just migrate this other separate repo into core. We might decide that it supersedes |
It sounds like Newtype will still need to exist, if only to add those functional dependencies. |
Not necessarily - I think it's possible that in practice, the lack of the functional dependency isn't an issue. If you always supply the newtype constructor as the first argument, which I would guess most people probably do, then both types are already determined by that argument, so the functional dependency doesn't give you any additional information. |
In other words, creating a function like un :: forall t a. Coercible t a => (a -> t) -> t -> a
un _ = coerce |
Closing now that #24 was merged. |
I cherry-picked kl0tli's commit, but resolved the merge conflicts by setting dependencies to
master