-
Notifications
You must be signed in to change notification settings - Fork 24
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
Unwrapping newtype should be easier than coercedTo
.
#484
Comments
newtype N1 = N1 Int deriving newtype Num
newtype N2 = N2 N1 deriving newtype Num
n2 :: N2
n2 = N2 $ N1 3
hmm = n2 & coercedTo %~ (*2) Now, does |
I didn't really think about nested newtypes. But, there is |
That uses |
I don't think there's any fundamental reason why we couldn't port |
I think it's not worthy copying Firstly, it's not just newtype unwrapper, there is instance Wrapped (Seq a) where
type Unwrapped (Seq a) = [a] for example. Secondly, there is https://hackage.haskell.org/package/newtype and https://hackage.haskell.org/package/newtype-generics which kind of do similar thing, but interestingly there is no I don't think that yet another take should be added to |
A minimal example of unwrapping a newtype
@Int
bugs me. When I unwrap a newtype, I shouldn't have to specify the wrapped type.coerced
often fails to infer the right types without explicit type declarations.The text was updated successfully, but these errors were encountered: