Skip to content
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

Pattern matching on data constructors with Rank N functions #42

Open
fxdpntthm opened this issue May 24, 2022 · 0 comments
Open

Pattern matching on data constructors with Rank N functions #42

fxdpntthm opened this issue May 24, 2022 · 0 comments
Labels
Low Priority Things that are good to have but not needed

Comments

@fxdpntthm
Copy link
Collaborator

fxdpntthm commented May 24, 2022

newtype NT m a = MkNT {unNT :: forall b. a -> m b}

foobar1 :: (b -> a) -> NT m a -> NT m b
foobar1 f nt = MkNT $ \ a -> unNT nt (f a)

foobar2 :: (b -> a) -> NT m a -> NT m b
foobar2 f (MkNT nt) = MkNT $ \ a -> nt (f a)

Although they both should work, foobar1 doesn't. The use of unNT gives rise to a wanted m @ b constraint.
one could type foobar1 :: Total m => (b -> a) -> NT m a -> NT m b. The total constraint is needed here as m as it can be applied to any b

@fxdpntthm fxdpntthm added the Low Priority Things that are good to have but not needed label May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Low Priority Things that are good to have but not needed
Projects
None yet
Development

No branches or pull requests

1 participant