Add deriving for Data.Newtype#2326
Conversation
| throwError . errorMessage $ CannotDeriveNewtypeForData name | ||
| go (DataDeclaration Newtype name _ dctors) = do | ||
| checkNewtype name dctors | ||
| let (ctorName, [ty]) = head dctors |
There was a problem hiding this comment.
Why not match this as a singleton above?
There was a problem hiding this comment.
Could do, but if you have an invalid newtype you'll get an error about an un-derivable class before you get the error that the newtype is invalid (since the check is made during type checking), which seems... not very useful.
There was a problem hiding this comment.
Ah ok. We can revisit this after I move deriving into the solver then.
| "purescript-st": "1.0.0-rc.1", | ||
| "purescript-partial": "1.1.2" | ||
| "purescript-partial": "1.1.2", | ||
| "purescript-newtype": "0.1.0" |
There was a problem hiding this comment.
I assume this will be bumped to 1.0 eventually?
There was a problem hiding this comment.
Yeah, I just made a release so we could add the test thing - we'll need to make a 2.0 prelude anyway, so when that is released the dependency will need bumping in newtype, at which point it'll be worth releasing as 1.0... phew 😉
| go (DataDeclaration Data name _ _) = | ||
| throwError . errorMessage $ CannotDeriveNewtypeForData name | ||
| go (DataDeclaration Newtype name _ dctors) = do | ||
| checkNewtype name dctors |
There was a problem hiding this comment.
This will be caught at the newtype definition, won't it?
|
👍 Looks good, thanks! I keep wondering about implementing GHC-style Generics as well, but that's probably too much work for 0.10. Hopefully we can add it in a minor release as a non-breaking change. |
|
Tests are passing again now - looks like one of them was depending on a misbehaving |
|
Looks good! |
Resolves #2314