Skip to content

[Documentation] Trying to rewrite typeclasses-new #8147

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 29 commits into from
Mar 30, 2020

Conversation

aesteve
Copy link
Contributor

@aesteve aesteve commented Jan 30, 2020

When first looking at this part of the doc, it wasn't completely clear to me.

For example:

Given instances, extension methods and context bounds allow a concise and natural expression of typeclasses.

I didn't really understand if extension methods and context bounds are needed to define a type class or if they simply help using them.

Typeclasses are just traits with canonical implementations defined by given instances

Simply using "whose" here helped me a bit. "Typeclasses are traits" (ok, so they're some abstract definition, fine), "whose implementation is" (oh ok, so this is the way of implementing the trait that differs, fine).

And finally, since the object Monoid with its apply method confused me a bit (is this part of a typeclass declaration?) I chose to first define the typeclass and use it without the object using summon, then add the object and remove summon.

Note that this is a "parti-pris" to rewrite the doc in a more "progressive" (or "tutorial") manner. And this may not be desirable feel free to tell me. That's not because I find it easier to understand this way, that everyone will...

Thanks for your reviews.

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@aesteve aesteve changed the title Trying to rewrite typeclasses-new [Documentation] Trying to rewrite typeclasses-new Jan 30, 2020
```scala
assert(3 == List(1, 2).combineAll)
```

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for doing this, it's a lot more with the style of the rest of the documentation. If you apply the same style to the Functors and Monads section this will be really nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I'm not sure I have enough knowledge to re-write the Functor/Monad part in the same fashion (you need to understand properly to explain properly) but I will definitely give it a try.
If I'm struggling I'll ping you, so that you know you can merge this as is (best if the ennemy of good ;) ). But that's worth trying.

@aesteve aesteve changed the title [Documentation] Trying to rewrite typeclasses-new [WIP] [Documentation] Trying to rewrite typeclasses-new Jan 31, 2020
@aesteve aesteve requested a review from bishabosha January 31, 2020 10:00
@aesteve
Copy link
Contributor Author

aesteve commented Jan 31, 2020

I added parts re. functors and monad but left apart the Reader Monad.
I think I understand what it does and what it's useful for, but it's still hard to find the appropriate words to explain in trivial terms as in the other examples.

@aesteve aesteve requested a review from odersky January 31, 2020 10:34
Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time to write this tutorial. I think it will help people a lot. I've just made a few suggestions concerning correct use of definitions.

Arnaud ESTEVE added 2 commits February 9, 2020 13:35
…asses-new

# Conflicts:
#	docs/docs/reference/contextual/typeclasses-new.md
@aesteve aesteve changed the title [WIP] [Documentation] Trying to rewrite typeclasses-new [Documentation] Trying to rewrite typeclasses-new Feb 9, 2020
@aesteve
Copy link
Contributor Author

aesteve commented Feb 9, 2020

Ready for review / merge.

Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

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

you will need to change the filename to drop the -new now

@aesteve
Copy link
Contributor Author

aesteve commented Feb 13, 2020

I have read that maybe we'll go back to given as so maybe I should still wait for a bit?

@aesteve aesteve requested a review from bishabosha February 26, 2020 07:33
@aesteve
Copy link
Contributor Author

aesteve commented Feb 27, 2020

I renamed given ... : to given ... as


The definition of a _typeclass_ is expressed via a parameterised type with abstract members, such as a `trait`.
The main difference between object oriented polymorphism, and ad-hoc polymorphism with _typeclasses_, is how the definition of the _typeclass_ is implemented, in relation to the type it acts upon.
In the case of a _typeclass_, its implementation for a concrete type is expressed through a `given` term definition, which is supplied as an implicit argument alongside the value it acts upon. With object oriented polymorphism, the implementation is mixed into the parents of a class, and only a single term is required to perform a polymorphic operation.
Copy link
Member

Choose a reason for hiding this comment

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

I think this part about comparing to OOP could be moved to the start

@bishabosha
Copy link
Member

@aesteve What do you think about moving the comparison with OOP polymorphism?

@bishabosha bishabosha assigned bishabosha and unassigned aesteve Mar 23, 2020
@aesteve
Copy link
Contributor Author

aesteve commented Mar 24, 2020

Hello.

Mixed feelings about this.

We could move the OO comparison at start (and remove the part about "it's just traits" or move it at the end) indeed.
In fact it depends which kind of reader we're trying to target.

For people who just want "I know, I know, just show me the syntax" a big intro with OOP comparison sounds quite "heavy", for people who don't know anything about typeclasses AND are familiar with OOP, it's accurate to have it at the start.

Honestly, that's quite a big "I don't know" for my part.

Do you want me to move it? Or should I give you access to my fork so that you can change it, or ?

@bishabosha
Copy link
Member

bishabosha commented Mar 24, 2020

For people who just want "I know, I know, just show me the syntax" a big intro with OOP comparison sounds quite "heavy", for people who don't know anything about typeclasses AND are familiar with OOP, it's accurate to have it at the start.

Honestly, that's quite a big "I don't know" for my part.

Maybe there can be an "aside" or some sort of box that can be skipped, my main concern was just that putting it at the very end seemed maybe out of place

@bishabosha
Copy link
Member

bishabosha commented Mar 29, 2020

I think in balance we would like to get this through, so If the wildcard type arguments are updated to use ? then this can be merged, thank you again for taking this on :)

@aesteve
Copy link
Contributor Author

aesteve commented Mar 30, 2020

Oh sorry, I've missed some changes to upstream. Can you point me at the change, please?

@bishabosha
Copy link
Member

@aesteve
Copy link
Contributor Author

aesteve commented Mar 30, 2020

Waw, didn't know about that :)

Should be ok now!

Re. the aside block, I may find a better organization in the future, but have unfortunately no time to look at it right now. Hopefully it's good enough as is, and can be reworked later on!

Thanks.

@bishabosha
Copy link
Member

Great, thank you :)

@bishabosha bishabosha merged commit 3eafc18 into scala:master Mar 30, 2020
@bishabosha
Copy link
Member

This is now published

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.

5 participants