Skip to content

Instantly share code, notes, and snippets.

View alkozin's full-sized avatar

Alexander Kozin alkozin

  • El Machine
  • Novosibirsk, Russian Federation
  • 19:41 (UTC +07:00)
View GitHub Profile
//Working examples
//Async
//Anything from Nothing
|{ (anything: Anything) in
🧙🏼
}
//Determinate user's location
|{ (location: CLLocation) in
extension CLLocation: Asking, Expectable {
static func ask<E>(with: Any?, in pipe: Pipe, expect: Expect<E>) {
let source = with as? CLLocationManager ?? pipe.get()
let handler = { (status: CLAuthorizationStatus) -> Bool in
guard status != .notDetermined else {
return true
}
|{ (permission: CLAuthorizationStatus) in
}
//Anything from Something
let anything: Anything = something|
let i: Int = float|
let string: String = data|
let front: UIColor = 0x554292|
let back: UIColor? = "#554292"|
//Look to geolocation permissions request to illustrate.
//Request is constructed according to `with` object
//
//Ask always permissions only if `ask` `with` `CLAuthorizationStatus.authorizedAlways` input argument
//Otherwise `ask` only in use permissions
//
extension CLAuthorizationStatus: Asking {
static func ask<E>(with: Any?, in pipe: Pipe, expect: Expect<E>) {
let source = with as? CLLocationManager ?? pipe.get()
Expect.every { T in
}
Expect.while { T in
true
}
let expect = Expect.one { T in
//Recognize 4 hands on input
let pipe = |{ (hands: [VNHumanHandPoseObservation]) in
}
let request: VNDetectHumanHandPoseRequest = pipe.get()
request.maximumHandCount = 4
let preview: AVCaptureVideoPreviewLayer? = pipe.get()
view.layer.addSublayer(preview!)
| .every { T in
} | .one { U in
} | .any { some in
} | .all { last in
}
| .every { T in
} | .one { U in
} | .while { E in
true
}
|.every { T in
}
|.one { T in
}
|.while { T in
true