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

Can anyone explain what is a functor and a monad is😭 #599

Open
neverdivideby0 opened this issue Apr 27, 2022 · 8 comments
Open

Can anyone explain what is a functor and a monad is😭 #599

neverdivideby0 opened this issue Apr 27, 2022 · 8 comments

Comments

@neverdivideby0
Copy link

sos

@zmchang3009
Copy link

hi! from my understanding, a functor is a context that makes use of map(). for eg, given a Context[something], we can map functions of type Function<? super T, ? extends T> to get Context[somethingElse].

a monad on the other hand makes use of flatMap(). so, given the same Context[something], we use flatMap() to apply functions of type Function<? super T, Context<? extends T>> to get Context[somethingElse].

since Optional makes use of both map() and flatMap(), it's both a functor and a monad.

but this is just based on my understanding of how to differentiate them though. it may not be entirely accurate and there are definitely proper ways of defining them (using the laws maybe...?)

@jamietan123
Copy link

^does anyone know if functors and monads are tested?

@jonghyunsohn
Copy link

Monads and functors are tested since it's part of Lecture 11.

@Brianliew77
Copy link

Do look at the laws covered in the lecture slides regarding the laws of functions & monads to see what classifies as functors and monads.

From my understanding, something would be considered a functor if

  1. it has a method map
  2. it obeys functor laws of identity and associativity

Something would be considered a monad if it fulfils all

  1. Right identity
  2. Left identity
  3. Associative

@summerthia02
Copy link

my TA mentioned that monads and functors aren't tested

@Brianliew77
Copy link

Hi, my TA says it can be tested! Everything except the implementation of Infinite Lists and Asynchronous Programming/CompletableFuture is tested!

@summerthia02
Copy link

oh ggg!! :o

@spicyseaweed
Copy link

tbh abit hard to understand..

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

No branches or pull requests

7 participants