profile
viewpoint
Charles Maria Tor Qata @MonadicConsulting Sydney I'm a programming consultant with a penchant for functional (reactive) programming.

Qata/BarMagnet 177

An iOS app that interfaces with remote torrent clients

ReSwift/ReactiveReSwift 133

Unidirectional Data Flow in Swift via FRP - Inspired by Elm

Qata/Magnetar 54

A top secret rewrite of BarMagnet

Qata/Recombine 27

Unidirectional data flow with Combine

Qata/MonadicJSON 10

A JSONDecoder that correctly preserves the values of floating point numbers

Qata/homebridge-twilio-sms 2

Homebridge plugin to make SMSes with a static message using Twilio api (paid service)

Qata/NSBencodeSerialization 1

A bencoding decoder and serialiser for those who don't like crashes.

IssuesEvent

issue closedapple/swift-algorithms

A `first` operator that returns the first non-nil transformed value

I found myself often having to find the first element in an array that passes an optional initialiser. If I wanted to stick to a purely functional paradigm (which I do, I'm a zealot) I need to do some pretty not-ideal transforms to allow this behaviour without defining a new function.

let value = ["Hello", "10"].lazy.map(Int.init).first { $0 != nil }.flatMap { $0 }

This could be trivialised with the following (naive) implementation.

public extension Sequence {
    /// Returns the first element in `self` that `transform` maps to a `.some`.
    func first<Result>(of transform: (Element) throws -> Result?) rethrows -> Result? {
        for value in self {
            if let value = try transform(value) {
                return value
            }
        }
        return nil
    }
}

closed time in 5 days

Qata

issue commentapple/swift-algorithms

A `first` operator that returns the first non-nil transformed value

Let the bikeshedding commence #31

Qata

comment created time in 5 days

PR opened apple/swift-algorithms

Add Sequence.firstNonNil(of:)

Description

firstNonNil(of:) returns the first value that is resolved by the passed transform to a non nil (.some) value.

Detailed Design

extension Sequence {
    /// Returns the first element in `self` that `transform` maps to a `.some`.
    func firstNonNil<Result>(of transform: (Element) throws -> Result?) rethrows -> Result?
}

Documentation Plan

Added documentation comments to the new function.

Test Plan

Five tests have been added.

Source Impact

None

Checklist

  • [x] I've added at least one test that validates that my change is working, if appropriate
  • [x] I've followed the code style of the rest of the project
  • [x] I've read the Contribution Guidelines
  • [x] I've updated the documentation if necessary
+48 -0

0 comment

2 changed files

pr created time in 5 days

push eventQata/swift-algorithms

Charles Maria Tor

commit sha 3a13c14bcac1dcc9c43d74b85b512ac345f9b7df

Rename First.swift to FirstTests.swift

view details

push time in 5 days

push eventQata/swift-algorithms

Charles Maria Tor

commit sha 2895485a3dbba2d146f5445979773c5a554e6bc7

Add Sequence.firstNonNil(of:) and associated tests

view details

push time in 5 days

fork Qata/swift-algorithms

Swift Algorithms is an open-source package of sequence and collection algorithms, along with their related types.

fork in 11 days

issue commentapple/swift-algorithms

A `first` operator that returns the first non-nil transformed value

@natecook1000 What's the next step from here? Does naming bike-shedding happen on this issue or on an actual PR?

Qata

comment created time in 11 days

startedapple/swift-algorithms

started time in 11 days

push eventReSwift/Recombine

Charles Maria Tor

commit sha 3cd8503005cb46a373073add68d9d1f7b8b433d5

Update README.md

view details

push time in 11 days

push eventReSwift/Recombine

Charles Maria Tor

commit sha ee4c86330f10a295cf28ffce7eea458aa2e5bb83

Update README.md

view details

push time in 11 days

created tagReSwift/Recombine

tag0.5.2

created time in 11 days

release ReSwift/Recombine

0.5.2

released time in 11 days

push eventReSwift/Recombine

Charles Maria Tor

commit sha ad45a172effb7fc9e82d7a090ca857aaa48052e1

Make StoreTransform a Subscriber, remove iOS 14 limit to lensing

view details

push time in 11 days

startedrhysforyou/BarMagnet

started time in 11 days

issue commentQata/BarMagnet

Feature Request - Choose directory on torrent addition

I do intend to add this feature to the Magnetar rewrite. The workaround I personally use is to set up multiple servers and switch before adding a torrent. Not ideal, I know, but I'm not maintaining the project anymore, even for my personal problems with the app. I don't have the time.

VrtlBrown

comment created time in 11 days

issue closedQata/BarMagnet

"Random" notifications

I was glad to discover that the app also sends notifications when a torrent download is completed. The problem is that this happens randomly and not for all torrents. Is it an iOS background refresh related issue?

closed time in 11 days

niccolospa

create barnchReSwift/Recombine

branch : master

created branch time in 11 days

created tagReSwift/Recombine

tag0.5

created time in 11 days

create barnchReSwift/Recombine

branch : mutable_state

created branch time in 11 days

created tagReSwift/Recombine

tag0.5.1

created time in 11 days

created repositoryReSwift/Recombine

created time in 11 days

push eventQata/Recombine

Charles Maria Tor

commit sha 5a9a2df29c49b9331a79b73395374d418d26d162

Make lensing public

view details

push time in 12 days

push eventQata/Recombine

Charles Maria Tor

commit sha cea2b8e2ac0c865b853cc0a7403346693041360f

Add StoreTransform

view details

push time in 12 days

push eventQata/Recombine

Charles Maria Tor

commit sha 7d7a8e74eb88640d6afff255b35e86f113997dd3

Add callAsFunction support to Reducers

view details

push time in 12 days

push eventQata/Recombine

Charles Maria Tor

commit sha bf2c748815fb97ce55b3a115b05ed2460721593d

Change state to @Published

view details

push time in 12 days

issue openedapple/swift-algorithms

A `first` operator that returns the first non-nil transformed value

I found myself often having to find the first element in an array that passes an optional initialiser. If I wanted to stick to a purely functional paradigm (which I do, I'm a zealot) I need to do some pretty not-ideal transforms to allow this behaviour without defining a new function.

let value = ["Hello", "10"].lazy.map(Int.init).first { $0 != nil }.flatMap { $0 }

This could be trivialised with the following (naive) implementation.

public extension Sequence {
    /// Returns the first element in `self` that `transform` maps to a `.some`.
    func first<Result>(of transform: (Element) throws -> Result?) rethrows -> Result? {
        for value in self {
            if let value = try transform(value[keyPath: path]) {
                return value
            }
        }
        return nil
    }
}

created time in 13 days

issue closedQata/Magnetar

[Q&A] Magnetar status and potential release date?

So im not much aware of swift and how fast they develop as i never worked with it. Id love to know whats the curent status of magnetar and if truly waiting swift 6 having any clue how fast we could expect it out and thus when Magnetar will be out. Are we talking in months or years and years to wait?

closed time in 22 days

AlexR00T

issue commentQata/Magnetar

[Q&A] Magnetar status and potential release date?

I can't give a definitive deadline, this is a pet project with some hard technical challenges that I am still unsure how to address. Most of my spare time is currently going to writing a novel, which I'm hoping to have done by mid 2021.

My advice is not to hold your breath on this project, especially while BarMagnet is still functional. My priorities might change if parts of BarMagnet stop working. I'm sorry I can't devote more time to it at the moment.

AlexR00T

comment created time in 22 days

startedzetzit/zz

started time in a month

more