- Type: Design proposal
- Author: Viacheslav Makarov
- Status: Draft
Reduce the need in @UnsafeVariance. Allow covariant types to have non-private methods
with non-covariant signature. To protect class' covariance, out-project signatures
| import Control.Category | |
| import Prelude hiding (id,(.)) | |
| import Control.Arrow | |
| data StreamProcessor a b = | |
| Put b (StreamProcessor a b) | Get (a -> StreamProcessor a b) | |
| instance Category StreamProcessor where | |
| id = arr id |
| type TypeFromString<T extends string> = | |
| T extends "number" ? number | |
| : T extends "string" ? string | |
| : ["Invalid type string", T] | |
| type InferPropRequired<PropSpec> = PropSpec extends { isRequired: false } ? false : true | |
| type InferPropType<PropSpec> = | |
| PropSpec extends { values: ReadonlyArray<infer Values> } ? Values | |
| : PropSpec extends { type: infer T extends string } ? TypeFromString<T> | |
| : ["Invalid prop spec", PropSpec] |
| import io.reactivex.Observable | |
| import io.reactivex.subjects.BehaviorSubject | |
| import io.reactivex.subjects.PublishSubject | |
| import java.util.concurrent.atomic.AtomicBoolean | |
| fun <T, R> Observable<T>.flatMapFirst(transform: (T) -> Observable<R>) = | |
| Observable.defer { | |
| val busy = AtomicBoolean() | |
| return@defer this | |
| .filter { busy.compareAndSet(false, true) } |