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

Support lenses for fields of higher rank types with GHC >= 9.2 #357

Open
arybczak opened this issue Sep 28, 2020 · 0 comments
Open

Support lenses for fields of higher rank types with GHC >= 9.2 #357

arybczak opened this issue Sep 28, 2020 · 0 comments

Comments

@arybczak
Copy link
Collaborator

With https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3220 merged (:tada: :exclamation: :tada:), the following compiles with GHC 9.1.0_20200927:

data Rank2 = Rank2 { rank2_x :: forall a. a -> a }

rank2_x_lens :: Lens' Rank2 (forall a. a -> a)
rank2_x_lens = lensVL $ \f (Rank2 x) -> (\x' -> Rank2 x') <$> f x

instance
  ( a ~ (forall x. x -> x)
  , b ~ (forall x. x -> x)
  ) => LabelOptic "x" A_Lens Rank2 Rank2 a b where
  labelOptic = rank2_x_lens

There are some unification issues that prevent convenient usage without intermediate type signatures (https://gitlab.haskell.org/ghc/ghc/-/issues/18759), but once they're ironed out, we'll be able to support all fields via labels :)

@arybczak arybczak changed the title Support lenses/labels for fields of higher rank types with GHC >= 9.1 via QL impredicativity Support lenses for fields of higher rank types with GHC >= 9.1 Oct 11, 2020
@arybczak arybczak changed the title Support lenses for fields of higher rank types with GHC >= 9.1 Support lenses for fields of higher rank types with GHC >= 9.2 Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant