-
Notifications
You must be signed in to change notification settings - Fork 17
add Scala functor example #10
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
Conversation
Sorry, didn't see that someone already provided with Scala examples. Should check Pull Requests first next time) But just in case i`ll reopen it. |
@DzyubSpirit can you please review this? |
Yeah, sure :) |
This PR tries different from #9. I would say #9 approach is more like Javascript and this PR is more like Haskell in terms of functor definition. #9 and Javascript just implement map method in every functor type (Maybe, Either, Array...). This PR and Haskell typeclasses additionally create Functor entity which is an abstraction of more concrete types (Maybe, Either, Array...) |
Scala/Maybe2.scala
Outdated
import Maybe._ | ||
import FunctorSyntax._ | ||
|
||
print(just("2").fmap(_.toDouble).fmap(a => a + 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(just("2").fmap(_.toDouble).fmap(a => a + 3)) | |
println(just("2").fmap(_.toDouble).fmap(a => a + 3)) |
Just added README, refactored names, moved to Scala/Advanced folder and added comments about the second example, please check it once more. @DzyubSpirit |
Good work! |
Provided Functor example for a Scala language. Functor is implemented using typeclass in Scala and usually is provided by some library like Cats or Scalaz where it is much more complicated than in this simple example.