Giter Site home page Giter Site logo

functionaljson-swift's Introduction

functionaljson-swift's People

Contributors

tonyd256 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  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

functionaljson-swift's Issues

Perform request issuse

Hi,
I have a problem. I cannot make this project working. I try to get a user from a web reguest and to do that, I am invoking this function:

performRequest(request: req) { (user) -> () in
println("user callback raised!")
}

But every time i try to build my code I get the following error:
/Users/SM/Downloads/FunctionalJSON-swift-d3fcf771c20813e57cb54472dd8c55ee33e87ae4/FunctionalJSON/ViewController.swift:19:9: Cannot convert the expression's type '(request: @lvalue NSURLRequest, (($T3) -> ()) -> ())' to type 'JSONDecodable'

Could you please help me?
Thanks!

Nested model parsing

I am trying to get nested model parsing to work, but without any success. The Xcode keeps hanging and crashing. :(

I tried to move the mapping block to separate class method like:

extension Location: JSONDecodable {
  static func create(lat: Double)(lon: Double) -> Location {
    return Location(lat: lat, lon: lon)
  }  

public static func mapper(d: JSONObject) -> Location? {
    return Location.create
        <^> d <|  "lat"
        <*> d <|  "lon"
  }
}

and then in parent model trying to parse it:

extension Post: JSONDecodable {
  static func create(id: Int)(subject: String)(location: Location) -> Post2 {
    return Post2(id: id, subject: subject, location: location)
  }

  public static func mapper(d: JSONObject) -> Post2? {
    return Post2.create
        <^> d <|  "id"
        <*> d <|  "subject"
        <*> (d <| "location") >>> Location.mapper
  }
}

after that when I hit Build, the SourceKit crashes, switfc compiler hangs and after a while, Xcode too (using Xcode 6.0.1)

Tests are not failing

I was curious about how the operator >|* works, so I went and tried breaking the tests. But to my surprise I wasn't able to. I even tried this:

func testBrokenTest() {
    assert("a" == "b")
}

So I took a look at the test settings in the default project, and instead of using assert, XCTest uses XCTAssert, and changing the previous example accordingly breaks the tests:

func testBrokenTest() {
    XCTAssert("a" == "b")
}

Changing all instances of assert for XCAssert allow the tests to fail when you change the operator >|* for >| in UserExtension.swift, and now I get it allows for optional values.

I would be happy to issue a pull request with the change. Also, amazing post, really answers many questions I had around functional programming and functional programming in Swift. Thanks!

License?

Tony, could you clarify what license this code is under?

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.