Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

part 3.2, 'Adjunctions' #56

Merged
merged 1 commit into from
Mar 12, 2018
Merged

Conversation

Zelenya
Copy link
Contributor

@Zelenya Zelenya commented Feb 18, 2018

Fixes #26

................
```Haskell
class (Functor f, Representable u) =>
Adjunction f u | f -> u, u -> f where
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Omitted functional dependencies in scala version

Copy link
Contributor

@SystemFw SystemFw left a comment

Choose a reason for hiding this comment

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

Very minor stuff

return :: d -> m d
```
```scala
def `return`[D]: D => M[D]
Copy link
Contributor

Choose a reason for hiding this comment

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

an M[_] type parameter is missing here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here, m is the (endo-) functor corresponding to R∘L, and w is the (endo-) functor corresponding to L∘R. As we’ll see later, they are part of the definition of a monad and a comonad, respectively.

It seemed to me like kind of a concrete example, however simplified:

 trait Extract[M[_]] { // ingnore
  def return[D](d: D): M[D]
} //ignore

extract :: w c -> c
```
```scala
def extract[C]: W[C] => C
Copy link
Contributor

Choose a reason for hiding this comment

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

a W[_] type parameter is missing here

implicit val F: Functor[F],
val U: Representable[U]
){
def unit[A](a: => A): U[F[A]]
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you decide to make a byname here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't remember why I've added it, and don't see a reason to keep it.

/* changed the order of parameters
to help scala compiler infer types */
def leftAdjunct[A, B]
(a: => A)(f: F[A] => B): U[B]
Copy link
Contributor

Choose a reason for hiding this comment

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

same question wrt byname

Copy link
Contributor

Choose a reason for hiding this comment

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

Changing parameter order makes sense from a scala perspective, but it might make seeing the relationship harder if one doesn't also read the haskell code

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 why I've added a comment.

The reasons to change the order in scala version:

  1. We are still going to do it in scala for sometime
  2. This example: rightAdjunct(a)(identity)

rightAdjunct f = counit . fmap f
```
```scala
def unit[A](a: => A): U[F[A]] =
Copy link
Contributor

Choose a reason for hiding this comment

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

byname

rightAdjunct(a)(identity)

def leftAdjunct[A, B]
(a: => A)(f: F[A] => B): U[B] =
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@kailuowang kailuowang merged commit a90242b into typelevel:master Mar 12, 2018
@kailuowang
Copy link
Contributor

merged since I think all feedback addressed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants