Add Swiftz to Selm
kylelol opened this issue · comments
Should we make SwiftZ library https://github.com/typelift/Swiftz a dependency of Selm instead of just the example project?
@kylelol
What are the possible features by depending on Swiftz?
I think it would be nice to have a few operators like
|>
, <|
, and •
(<<
)
Those are the three that the Elm language provides to help with function composition.
That way we can start making the implementation more functional.
For example I could change the map
function on Task<A>
from an instance function to a static function, and made it curried
// In Task<A>
static func map<A, B>(_ transform: @escaping (A) -> B) -> (Task<A>) -> Task<B> {
...
}
// At call site
let transform = { someA in return someB }
let taskA = Task<A>()
let taskB = taskA |> Task.map(transform)
I'd be open to just implementing the operators ourselves, but I saw you included the Swiftz dependency in the example project, so I was not sure if it made sense to just move it to Selm
@kylelol
Selm becomes handy probably, as you say.
Would you write Selm code with Swiftz?
@rizumita I honestly would probably only want to use those 3 operators I mentioned above |>, <|, and •(<<)
inside Selm code for now.
@kylelol If only operators, I think Selm depends only on Swiftx perhaps. Do we need a Monad by depending on Swiftz?
@rizumita I would probably not need a Monad from swifz.
I would more than likely just implement the functions required for a Monad myself, such as bind
@kylelol
OK, let's use a suitable one, either Swiftx or Swiftz.