Skip to content

Make methods return Unit #53

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

Merged
merged 42 commits into from
Dec 21, 2017
Merged

Make methods return Unit #53

merged 42 commits into from
Dec 21, 2017

Conversation

aztecrex
Copy link
Contributor

@aztecrex aztecrex commented Nov 8, 2017

No description provided.

@paf31
Copy link
Contributor

paf31 commented Nov 8, 2017

Thanks!

What do you think we should/can do about the Context2D function arguments? I was thinking if we're breaking things anyway, then we should make them consistent - either always the first, or always the last argument. Do you have any thoughts on that?

@aztecrex
Copy link
Contributor Author

aztecrex commented Nov 8, 2017

The OO part of me likes Context2D first but for PS functions, I want the arguments most likely to be partially-applied to come first. Agree it should be consistent to reduce friction. Otherwise, I don't have enough experience using the library to make a good recommendation.

@paf31 paf31 changed the title merged latest Make methods return Unit Nov 19, 2017
@paf31
Copy link
Contributor

paf31 commented Nov 19, 2017

I think we might want to partially apply either the arguments or the context, so I'm really not sure which is best :) but you're right that we should be consistent.

I think it's probably more likely that we'll want to partially apply the context, so let's go with that. Would you like to make that change? Or if you don't have time, I can take a look after this gets merged.

Thanks!

@aztecrex
Copy link
Contributor Author

happy to do it

@aztecrex
Copy link
Contributor Author

aztecrex commented Dec 3, 2017

Starting the re-ordering. Maybe I should also similarly re-order the Canvas operations. Thoughts?

@aztecrex
Copy link
Contributor Author

aztecrex commented Dec 3, 2017

Additional changes:

  • Context2D is first parameter
  • CanvasElement is first parameter
  • CanvasGradient is first parameter
  • addColorStop returns Eff Unit

```

Set the current font.

#### `fillText`

``` purescript
fillText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D
fillText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you miss this one?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, is there a reason why Context2D isn't last here like it is in the other methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

context2d should be first. that's what we discussed before. it's just that the docs aren't updated for the others. i'll commit a document update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's done. i hadn't realized generating documents is not part of the build

return function() {
canvas.width = width;
return canvas;
return {};
Copy link
Contributor

Choose a reason for hiding this comment

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

For reference, you don't need these, since values of type Unit can't be inspected, so you can return any value and the user won't be able to observe it.

There could be a small speedup to be had by not constructing these values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure. that's easy to change. just pushed an update

@@ -1,6 +1,8 @@
/* global exports */
"use strict";

const unit = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

My point was that you don't need to return anything in particular (or at all). Just omitting the return statement will be fine.

Copy link
Contributor Author

@aztecrex aztecrex Dec 21, 2017

Choose a reason for hiding this comment

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

Omitted. I would normally favor the explicit returns since they document intent.

psc-package.json Outdated
@@ -1,7 +1,7 @@
{
"name": "canvas",
"source": "https://github.com/purescript/package-sets.git",
"set": "psc-0.10.1",
"set": "psc-0.11.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just delete this file actually, it's not being used.

@hdgarrood
Copy link
Collaborator

@paf31 this looks good to me; do you have anything else to add or would you say this is good to merge?

@paf31
Copy link
Contributor

paf31 commented Dec 21, 2017

No, this looks great, I think we should release it. Thanks for your patience @aztecrex :)

@hdgarrood
Copy link
Collaborator

Great. I'd be happy to do so, although I don't have push access to this repo right now.

@paf31
Copy link
Contributor

paf31 commented Dec 21, 2017

Can you please try now?

@hdgarrood hdgarrood merged commit 3a5890c into purescript-web:master Dec 21, 2017
@hdgarrood
Copy link
Collaborator

Seems to work, thanks! I'll make a release when I'm next at my PC (on mobile right now).

@hdgarrood
Copy link
Collaborator

Actually, I was thinking I might try to address #22 first, if that sounds sensible?

@paf31
Copy link
Contributor

paf31 commented Dec 21, 2017

👍 Yep sounds good to me, thanks!

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.

3 participants