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

IndentOpt Existential Type #565

Open
eayus opened this issue Jul 23, 2024 · 1 comment
Open

IndentOpt Existential Type #565

eayus opened this issue Jul 23, 2024 · 1 comment

Comments

@eayus
Copy link

eayus commented Jul 23, 2024

The current definition of IndentOpt exposes the type variable b representing the type of block elements to be parsed. In my opinion it makes more sense to existentially quantify this variable in the constructors instead. This gives block parsers more flexibility on the type of items they are parsing.

The current definition is like this:

data IndentOpt m a b
  = IndentNone a
  | IndentMany (Maybe Pos) ([b] -> m a) (m b)
  | IndentSome (Maybe Pos) ([b] -> m a) (m b)

and I am suggesting changing it to:

data IndentOpt m a
  = IndentNone a
  | forall b. IndentMany (Maybe Pos) ([b] -> m a) (m b)
  | forall b. IndentSome (Maybe Pos) ([b] -> m a) (m b)

This also gives the type a straightforward Functor instance.

Is this a change you would consider accepting? It is not backwards compatible and would require the ExistentialQuantification extension. I'd be happy to make a PR.

@mrkkrp
Copy link
Owner

mrkkrp commented Sep 3, 2024

This is probably better typing in this case, yes. It would make sense to merge this if we ever decide to bump the major version, but I'm not sure when that will happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants