Code Monkey home page Code Monkey logo

typescript-ramda's Introduction

##Type definitions for Ramda

Test with:

tsc --module amd ramda-tests.ts

Will be pushed to DefinitelyTyped when finished.

Pull requests are welcome!

![Gitter](https://badges.gitter.im/Join Chat.svg)

##Usage and limitation To use the Ramda type definitions include the following line in each of the .ts files that use Ramda:

    /// <reference path="./path/to/ramda.d.ts" />

In Ramda almost all functions are curried. TypeScript is not equipped well to support this. We have tried to use TypeScript to its max and allow for curried functions to be applied in maximum two steps. For binary function you could do:

R.indexOf(10, [1,2,3,4])
R.indexOf(10)([1,2,3,4])

and for ternary functions

R.insert(2, 'x', [1,2,3,4])
R.insert(2)('x', [1,2,3,4])
R.insert(2, 'x')([1,2,3,4])

R.insert(2)('x')([1,2,3,4]) // => type error!

In the last application of insert TypeScript will complain that the supplied parameters do not match the target. However, this is a valid application of the Ramda function.

Another nice Ramda feature is the use of placeholders in curryed functions. Calling a function with placeholders creates a new (curryed) function with the placeholder arguments to be supplied later. It is similar to calling a curryed function with partial arguments, without to need to supply arguments from left to rigth. The next example of valid function applications of R.insert will clarify this:

R.insert(R.__, 'x', [1,2,3,4])(2)
R.insert(2, R.__, [1,2,3,4])('x')
R.insert(R.__, 'x', R.__)(2)([1,2,3,4])

TypeScript can recognize placeholders as specific types, but there are edge cases in with it fails to distinguish signature patterns correctly. These cases occur in ternary functions and function of higher order. Binary function pose no problem.

##Status The definitions are reorganized and updated and are more or less compatible with Ramda v0.15. The API of Ramda is not stable yet.

This needs to be done:

  • include all functions of v0.15
  • reorganize functions by categories (List, Object, Function, etc)
  • find a elegant way to reflect the Ramda categories into TypeScript interface names that are displayed when hovering over a function. At to moment R.List.<function name> is displayed, regardless of the real category a function resides.
  • Shorten function descriptions to one or two sentences to limit the size of the tooltip in some IDE's.

typescript-ramda's People

Contributors

jon49 avatar gitter-badger avatar

Watchers

Ruxo avatar James Cloos avatar

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.