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

Finishing up #1564 (add As a.k.a liskov) #1728

Merged
merged 16 commits into from
Jun 14, 2017
Merged

Conversation

kailuowang
Copy link
Contributor

@kailuowang kailuowang commented Jun 12, 2017

This is an effort to finish up #1564
complete the missing test with 2 new helper methods for Function1

Closes #1564

stew and others added 15 commits March 18, 2017 09:59
This is a direct port of the Liskov class from scalaz.  I named it `As` to be
similar to our new `Is` class representing type equality, but there are aliases
named `<~<` and `Liskov`
remove explicit reference to package in Is type alias (for posco)
add === type alias for `Is` (for sellout)
- change unsafeFromPredef to just use refl
- add tests for some expected relationships such as Int <~< Any,
  and List[String] <~< List[Any]
… derrived from what we have, and I can't find anyone using them in the wild)
Thank you very much @kailuowang for the solutiongit diff
@kailuowang kailuowang changed the title Finishing up #1564 Finishing up #1564 (add As a.k.a liskov) Jun 12, 2017
@codecov-io
Copy link

codecov-io commented Jun 12, 2017

Codecov Report

Merging #1728 into master will increase coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1728      +/-   ##
==========================================
+ Coverage    93.9%   93.99%   +0.08%     
==========================================
  Files         248      249       +1     
  Lines        4101     4129      +28     
  Branches      156      159       +3     
==========================================
+ Hits         3851     3881      +30     
+ Misses        250      248       -2
Impacted Files Coverage Δ
core/src/main/scala/cats/evidence/As.scala 100% <100%> (ø)
...ain/scala/cats/laws/discipline/CategoryTests.scala 100% <0%> (+16.66%) ⬆️
laws/src/main/scala/cats/laws/CategoryLaws.scala 100% <0%> (+33.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3944108...48f539f. Read the comment docs.

@kailuowang kailuowang added this to the 1.0.0-MF milestone Jun 13, 2017
@johnynek
Copy link
Contributor

looks great!

Thanks a ton @stew and @kailuowang (and prior scalaz authors).

@kailuowang kailuowang merged commit 2e01263 into typelevel:master Jun 14, 2017
@kailuowang kailuowang deleted the add-as branch June 14, 2017 20:32
@sir-wabbit
Copy link

Can Leibniz and Liskov type aliases be removed? I am not seeing the rationale behind having extra symbolic type aliases. They could be used for bounded versions of As and Is in the future.

@johnynek
Copy link
Contributor

johnynek commented Jun 15, 2017 via email

@sir-wabbit
Copy link

sir-wabbit commented Jun 15, 2017

Similar to https://github.com/alexknvl/leibniz/blob/master/src/main/scala/leibniz/Leibniz.scala
As it currently is, Is[A, B] can not be used to substitute into bounded type constructors such as F[A >: L <: H], even if you know that both A >: L <: H and B >: L <: H.

@johnynek
Copy link
Contributor

johnynek commented Jun 15, 2017 via email

@sir-wabbit
Copy link

sir-wabbit commented Jun 15, 2017

No. You can't get L <: A knowing only L <~< A, at least not with the available functionality of As (there are some tricks that you can do involving existential types, but it won't help with F[A >: L <: H]). The compiler won't let you write F[A] for F[X >: L <: H] because it has to know that such type constructor makes sense. You can't even asInstanceOf it since F[A] (or F[B]) will be a semantic error.

@sir-wabbit
Copy link

sir-wabbit commented Jun 15, 2017

Having A === B and knowing A >: L <: H and B >: L <: H is enough to justifiably coerce F[A] to F[B] using asInstanceOf. But unless you have a bounded version of Is, you can't do it without asInstanceOf.

@sir-wabbit
Copy link

sir-wabbit commented Jun 15, 2017

Similarly, having just As[A, H] and a: A is not enough to be able to call def foo[X <: H](x: X): Option[X] as foo[A](a) : Option[A], you need something along the lines of As1.

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.

6 participants