GithubHelp home page GithubHelp logo

naught's Introduction

Naught

For people who want to use Argo but do naught want to use custom operators.

Naught is meant to use in conjunction with Argo to form ...

ArgoNaught

... Get it?

Installation

github "thoughtbot/Naught"

Carthage will automatically download Argo as well since it is a dependency of Naught. However, if you want to use anything in Argo (most likely you will be) you will have to bring it into your project along with Naught.

coming soon

What's included?

You get 4 global functions to replace Argo's custom operators to use when parsing JSON:

  • getValue (json: JSONValue, key: String) replaces <|
  • getValueO(json: JSONValue, key: String) replaces <|?
  • getArray (json: JSONValue, key: String) replaces <||
  • getArrayO(json: JSONValue, key: String) replaces <||?

You also get a try function, good to up to 12 parameter model create functions. try let's you ignore fmap <^> and apply <*> and use a function instead.

struct User {
  let id: Int
  let name: String
  let email: String?
}

extension User: JSONDecodable {
  static func create(id: Int)(name: String)(email: String?) -> User {
    return User(id: id, name: name, email: email)
  }

  static func decode(j: JSONValue) -> User? {
    return try(User.create
      , getValue (j, "id")
      , getValue (j, "name")
      , getValueO(j, "email"))
  }
}

To see a full example of Naught's usage, please check out the tests.

naught's People

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.