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

Add preliminary support for trait in parser and typechecker. #186

Merged
merged 3 commits into from
Jul 13, 2015
Merged

Add preliminary support for trait in parser and typechecker. #186

merged 3 commits into from
Jul 13, 2015

Conversation

albertnetymk
Copy link
Contributor

No description provided.

@EliasC
Copy link
Contributor

EliasC commented Jun 15, 2015

Maybe it would be better to keep the trait development in a separate branch until it is fully ready to be merged into master? I'm happy to review it though.

@albertnetymk
Copy link
Contributor Author

My concern is that the final PR could be too big to be properly reviewed, so I creating PRs whenever some milestone is reached.

@EliasC
Copy link
Contributor

EliasC commented Jun 15, 2015

But you could still create pull requests to a branch (say encore/traits), which can be reviewed incrementally, and then merged with master when it is ready.

extractTypes (Program _ _ _ funs classes) =
List.nub $ concat $ concatMap extractFunctionTypes funs ++ concatMap extractClassTypes classes
extractTypes (Program{functions, classes}) =
List.nub $ concat $ concatMap extractFunctionTypes functions ++ concatMap extractClassTypes classes
where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good that these kind of refactorings are done!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually not refactoring. The original way does not build if I add more fields to Program. Using record syntax seems remove that constraint.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever you want to call it, I think using the record syntax is better.

@albertnetymk
Copy link
Contributor Author

I have pushed another commit based on the feedback. I could squeeze those two commits into one before merging if someone prefers that.


isMainMethod :: MonadReader Environment m => MethodDecl -> m Bool
isMainMethod method = isInMain >>= return . (&& (mname method == Name "main"))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being picky, but I don't like that these are in Environment.hs. First of all, the rest of the functions are not monadic but treat the environment as an argument. Secondly, isMainMethod is breaking abstraction by letting the environment be aware of the special names this and main. Even though these names will probably never change, I think the environment should be agnostic of such things. Here is a suggestion patch for a version that keeps abstraction:

https://gist.github.com/EliasC/2dbebda951e302a9f18f

Feel free to use this, modify it, or argue why I'm wrong :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Updated.

@EliasC
Copy link
Contributor

EliasC commented Jul 13, 2015

Looking really good now (although I'll be back on the snake_case...)! Merging now.

EliasC added a commit that referenced this pull request Jul 13, 2015
Add preliminary support for trait in parser and typechecker.
@EliasC EliasC merged commit 6fe98b0 into parapluu:master Jul 13, 2015
@EliasC EliasC deleted the trait branch July 13, 2015 18:41
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

Successfully merging this pull request may close these issues.

2 participants