Giter Club home page Giter Club logo

focus's People

Contributors

a2 avatar bkase avatar codafi avatar dymv avatar mpurland avatar pthariensflame avatar rpeckatl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

focus's Issues

ENABLE_BITCODE set to false during restructuring for SPM

Adding an issue for this before submitting a PR since I'm not sure if disabling was intentional or not. If it was intentional, was there a reason for disabling it? It seems like being in the Xcode project settings it would not impact SPM builds.

importing Focus and Swiftz cause operators such as ||| to fail to compile

import Swiftz 
import Focus

func fanin<A, B, C>(_ l: @escaping (A) -> C, _ r: @escaping (B) -> C) -> Function<Either<A, B>, C> {
    return Function.arr(l) ||| Function.arr(r)
}

The above fails to compile and there doesn't seem to be a way to specify which library you want the operator to come from since Swiftz.||| fails to compile.

***: error: ambiguous operator declarations found for operator
return Function.arr(l) ||| Function.arr(r)
^
:0: note: found this matching operator declaration
:0: note: found this matching operator declaration
***: error: operator is not a known binary operator
return Function.arr(l) ||| Function.arr(r)

Monomorphic Lenses?

The other Swift Lens framework, Monocle, has taken to a data-accessor-esque implementation of Lenses, and I think there's something to the idea of including a record-accessor structure with Focus. Especially since Swift doesn't allow polymorphic type aliases, and Monomorphic lenses are just easier to reason about for the general Swift programmer.

Optionals

Only they need a new name now because STL.

Optional traversal

Is there no way to lens through an optional? I've tried with Party.lpartyCaterer() • User.userName and Party.lpartyCaterer() • _Some • User.userName, to no avail.

// A party has a host, an optional caterer and an array of guests
class Party {
    var host : User
    var caterer : User?
    var guests : [User]

    init(h : User, c : User? = nil, g : [User] = []) {
        host = h
        caterer = c
        guests = g
    }

    class func lpartyHost() -> Lens<Party, Party, User, User> {
        let getter = { (party : Party) -> User in party.host }
        let setter = { (party : Party, host : User) -> Party in Party(h: host, c: party.caterer, g: party.guests) }
        return Lens(get: getter, set: setter)
    }

    class func lpartyCaterer() -> Lens<Party, Party, User?, User?> {
        let getter = { (party : Party) -> User? in party.caterer }
        let setter = { (party : Party, caterer : User?) -> Party in Party(h: party.host, c: caterer, g: party.guests) }
        return Lens(get: getter, set: setter)
    }

    class func lpartyGuests() -> Lens<Party, Party, [User], [User]> {
        let getter = { (party : Party) -> [User] in party.guests }
        let setter = { (party : Party, guests : [User]) -> Party in Party(h: party.host, c: party.caterer, g: guests) }
        return Lens(get: getter, set: setter)
    }
}

class PartySpec : XCTestCase {
    func testLens() {
        let party = Party(h: User("max", 1, [], "one"))
        let hostnameLens = Party.lpartyHost()  User.userName

        XCTAssert(hostnameLens.get(party) == "max")

        let updatedParty: Party = (Party.lpartyHost()  User.userName).set(party, "Max")
        XCTAssert(hostnameLens.get(updatedParty) == "Max")

        let catererLens = Party.lpartyCaterer()  User.userName

        let cateredParty: Party = (Party.lpartyCaterer()  User.userName).set(party, "Marc")
        XCTAssert(catererLens.get(updatedParty) == "Marc")

    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.