Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/christopherdavenport/rank3
https://github.com/christopherdavenport/rank3
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/christopherdavenport/rank3
- Owner: ChristopherDavenport
- Created: 2018-11-01T23:42:31.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-24T22:19:26.000Z (over 2 years ago)
- Last Synced: 2024-10-24T08:50:37.653Z (22 days ago)
- Language: Scala
- Size: 161 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rank3 [![Build Status](https://travis-ci.com/ChristopherDavenport/rank3.svg?branch=master)](https://travis-ci.com/ChristopherDavenport/rank3)
A set of algebras exposing operations for rank3 transformations. Such that the expression operates on
`F[_[_]]` and forall `H[_]`.To this end we currently expose 4 sets of rank3 constructs
```scala
trait Function1R3[F[_[_]], G[_[_]]]{
def apply[H[_]](a: F[H]): G[H]
}
type ~~> = Function1R3EitherR3[F[_[_]], G[_[_]], H[_]] = Either[F[H], G[H]]
IorR3[F[_[_]], G[_[_]], H[_]] = Ior[F[H], G[H]]
Tuple2R3[F[_[_]], G[_[_]], H[_]] = (F[H], G[H])
```Each of the algebras can be mixed to build arbitrary composition over rank3 values `forall * -> *`
## Example
```scala
trait Foo[F[_]]{
def foo: F[Int]
}
trait Bar[F[_]]{
def bar: F[Int]
}
val transform = new ~~>[Tuple2R3[Functor, Foo, ?[_]], Bar] {
def apply[F[_]](fh: Tuple2R3[Functor, Foo, F]): Bar[F] = new Bar[F]{
def bar = fh.fst.map(fh.snd.foo)(_ + 1)
}
}
```