Content-Length: 417963 | pFad | http://github.com/purescript/purescript/issues/1120

81 Allow forall in polymorphic instance heads · Issue #1120 · purescript/purescript · GitHub
Skip to content

Allow forall in polymorphic instance heads #1120

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

Open
michaelficarra opened this issue May 21, 2015 · 17 comments
Open

Allow forall in polymorphic instance heads #1120

michaelficarra opened this issue May 21, 2015 · 17 comments

Comments

@michaelficarra
Copy link
Contributor

I believe these are the only places where we don't require forall. Examples from the website:

class Sized a where
  size :: a -> Number

instance sizedArray :: (Sized a) => Sized [a] where
  size [] = 0
  size (x : xs) = size x + size xs

Proposed new requirement:

class forall a. Sized a where
  size :: a -> Number

instance sizedArray :: forall a. (Sized a) => Sized [a] where
  size [] = 0
  size (x : xs) = size x + size xs
@Fresheyeball
Copy link

@michaelficarra are you seriously opening issues during PureScript Conf?

@michaelficarra
Copy link
Contributor Author

@Fresheyeball Maybe. It's inspiring!

@paf31
Copy link
Contributor

paf31 commented May 24, 2015

👍

@garyb
Copy link
Member

garyb commented May 24, 2015

Is requiring forall a feature? I thought we only did that becasue we hadn't got around to allowing Haskell-style implicit typevars.

@hdgarrood
Copy link
Contributor

I find class forall a. Sized a where [...] a bit strange - first, you wouldn't be allowed to use a real type in that context (that is, class Sized Foo where [...] isn't allowed), and also, I think of class Sized a where as introducing a type variable a into the inner scope already, so there shouldn't be a need for an extra type-variable-introducing construct (that is, forall).

👍 for the instance part, though, I do find the current behaviour a bit jarring.

@paf31
Copy link
Contributor

paf31 commented Aug 8, 2015

I agree with @hdgarrood in theory, but in practice, this change is massive for relatively little gain IMO.

@paf31 paf31 modified the milestones: Ideas, 0.8.0 Aug 8, 2015
@michaelficarra
Copy link
Contributor Author

Also agreed with @hdgarrood. I still think this is an inconsistency worth fixing eventually. It's unfortunate that this got passed over for 0.7.0.

@jdegoes
Copy link

jdegoes commented Aug 8, 2015

One could at least allow explicit quantification syntax for a few versions.

@michaelficarra
Copy link
Contributor Author

Ah, good idea. If both are allowed, the current syntax can be deprecated using our new warning system.

@paf31 paf31 changed the title typeclass and instance heads don't quantify their type variables with forall Require 'forall' in polymorphic class and instance heads Nov 24, 2015
@paf31
Copy link
Contributor

paf31 commented Mar 10, 2016

Backlog?

@paf31 paf31 changed the title Require 'forall' in polymorphic class and instance heads forall in polymorphic instance heads Mar 10, 2016
@garyb
Copy link
Member

garyb commented Mar 10, 2016

Yeah, I think so.

@paf31 paf31 modified the milestones: 1.0.0, Ideas Mar 10, 2016
@paf31 paf31 changed the title forall in polymorphic instance heads Allow forall in polymorphic instance heads Oct 1, 2016
@natefaubion
Copy link
Contributor

I personally would still really like to see this. I find reading implicitly quantified instances difficult, and have even made silly typo mistakes due to this.

@jrairigh
Copy link

jrairigh commented Apr 7, 2021

I'd like to work on this feature, but am new to purescript. @natefaubion does #3824 affect this feature or the other way around?

@natefaubion
Copy link
Contributor

@jrairigh It's the other way around. Implementing this feature would likely affect the syntax of #3824.

@jrairigh
Copy link

jrairigh commented Apr 8, 2021

I'm guessing the changes would go somewhere in the CST parsing code. Is this correct? If not, could someone please point me in the right direction?

@hdgarrood
Copy link
Contributor

This would indeed go somewhere in the CST parsing code; probably by adding new cases to instHead in lib/purescript-ast/src/Language/PureScript/CST/Parser.y. I think we might also want to start emitting warnings for implicitly quantified variables in instances, and then turn that into an error later.

@jrairigh
Copy link

jrairigh commented Apr 9, 2021

I've added a new deprecated warning constructor to ParserWarningType called WarnDeprecatedInstHeadForallSyntax. What should the deprecation warning text to be?

e.g. Implicit 'forall' in instance head is deprecated and will be removed in a future release. Add 'forall' keyword to instance head.

Also, am I correct in assuming I should create a branch off of master and create the PR off of branch? Are there any other steps I've missed?

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

Successfully merging a pull request may close this issue.

8 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/purescript/purescript/issues/1120

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy