IxMonad
implies Monad
for (EDIT: Exists as LowerIx
with newtype LiftIx m i j a = LiftIx (m a)
)
and `
newtype Same :: (k -> k -> k' -> Type) -> (k -> k' -> Type) where
Same :: p f f a -> Same p f a
import Bow | |
import SwiftUI | |
public typealias Component<W: Comonad, V: View> = | |
Kind<W, SwiftUIBackendOf<CoOf<W, ()>, V>> | |
func const<A,B>(_ x: A) -> (B) -> A { return { _ in x } } | |
public final class ComponentView<W: Comonad, V: View>: View { | |
private var component: Component<W, V> |
import RxSwift | |
import RxFeedback | |
extension Observable where E == Any { | |
public static func system<State, Event, Environment>( | |
initialState: State, | |
reduce: @escaping (inout State, Event, Environment) -> [Effect<Event>], | |
scheduler: ImmediateSchedulerType, | |
environment: Environment, | |
feedback: [Feedback<State, Event>] |
// https://stackoverflow.com/questions/53011500/how-to-replace-properties-using-mapped-types-in-typescript | |
// https://twitter.com/inamiy/status/1278511811025711104 | |
type ReplaceProps<T, From, To> = { | |
[K in keyof T]: K extends keyof From | |
? T[K] extends From[K] | |
? K extends keyof To | |
? To[K] | |
: T[K] | |
: T[K] |
// Protocol to use for type erasure. | |
protocol Summable { | |
func sum() -> Int | |
} | |
// Concrete model. Type | |
extension Int: Summable { | |
func sum() -> Int { self } | |
} |
extension Effect { | |
func cancellable<Id: Hashable>(id: Id) -> Effect<Output> { | |
return Deferred { () -> PassthroughSubject<Output, Failure> in | |
cancellables[id]?.cancel() | |
let subject = PassthroughSubject<Output, Failure>() | |
cancellables[id] = self.subscribe(subject) | |
return subject | |
} | |
.eraseToEffect() | |
} |
public typealias CompletionHandler = Function<Void, Void> | |
public typealias SideEffect<Input> = Function<Input, Void> | |
public struct Function<Input, Output>: Identifiable { | |
public let id: String | |
internal let f: (Input) -> Output | |
public init( | |
id: String, |
IxMonad
implies Monad
for (EDIT: Exists as LowerIx
with newtype LiftIx m i j a = LiftIx (m a)
)
and `
newtype Same :: (k -> k -> k' -> Type) -> (k -> k' -> Type) where
Same :: p f f a -> Same p f a
First, head here to join our Zoom meeting. It will help me following along while you work through the assignment.
Write a program that calculates purchase price for movie tickets using any language you like. It should not be a full-blown web app; it can be a simple class or collection of methods invokable by your test suite. We'll provide you with some requirements, test-cases, and even a sample interface - all you have to do is give us some software.
// Paste into a macOS playground in Xcode and run. | |
// Deleting line 46 "c?.stopObserving()" triggers the assertion because | |
// the reference cycle caused by retaining self in the observer block is never broken. | |
import Foundation | |
let myNotification = NSNotification.Name(rawValue: "myNotification") | |
var cHasBeenDeallocated = false |
public struct AnyCodable: Codable { | |
public let value: Any? | |
public init(_ value: Any?) { | |
self.value = value | |
} | |
public init(from decoder: Decoder) throws { | |
let container = try decoder.singleValueContainer() | |