GithubHelp home page GithubHelp logo

mnn / typings-sanctuary Goto Github PK

View Code? Open in Web Editor NEW
12.0 5.0 2.0 45 KB

*UNMAINTAINED* type definitions (for TypeScript) for JavaScript library Sanctuary

TypeScript 90.30% Haskell 7.13% Shell 2.56%
sanctuary typescript typings javascript

typings-sanctuary's Introduction

Type definitions for Sanctuary (page, GitHub)

Just a reminder before using - do not expect 100% typings which are in my opinion impossible, because TypeScript's type (and module) system isn't just strong enough for all magic used in Sanctuary.

There are some nasty anys (sometimes masked behind empty interface or non-parameter generic) and on some places you have to help TS with types inferring (e.g. S.Nothing<number>()). If you can think of better solution than is in this typings, please consider making a PR.

Status

Almost everything is typed. Consider this project to be a beta version, there may be breaking changes (I will try to not break anything).

Installation

Fast

For now just a hacky solution. (Typings tool with GitHub address can't be used, because it doesn't support multiple files - it breaks typings for Maybe and other types.)

Run this in your project directory (it creates typings module directory in node_modules and downloads typings):

wget -qO- https://github.com/mnn/typings-sanctuary/raw/master/install.sh | bash -s

Local package

If you want a bit better solution you can try local package approach.

Create directory local_packages/typings-sanctuary in your project and download typings into that directory (typings are files in the directory sanctuary at this repo).

Create there package.json:

{
  "name": "@types/sanctuary",
  "version": "0.0.1",
  "author": "monnef"
}

Add it to your project's dependencies:

  "dependencies": {
    "@types/sanctuary": "./local_packages/typings-sanctuary"
   }

Run npm install and you should be all set.

Usage

After installation you should be able to compile and run following code (IntelliJ IDEA friendly version):

import SanctuaryMod = require('sanctuary/index');

const S = SanctuaryMod.create({checkTypes: false, env: SanctuaryMod.env});

console.log(S.add(1, 2));

Testing

To compile and execute sanctuary-tests.ts run (assuming npm install has been done):

npm test

typings-sanctuary's People

Contributors

kiaragrouwstra avatar mnn avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

typings-sanctuary's Issues

Publish on NPM

Similar topic: typed-typings/npm-ramda#96

Investigate if it is even possible - this project uses two type files, mainly to circumvent limitations of TypeScript. I suspect it is not, because when I tried to use this repo by typings tool (it supports github as a source), it concatenated all files - essentially hiding all sanctuary types (like Maybe and others). ๐Ÿ˜ž

Support for recent v0.12.0 release of S?

I found your work very useful. Do you plan to support recent versions of S? I am not sure my experience is enough to validate TS typings against latest S version.

Update typings to Sanctuary 0.12.*

Breaking changes

  • Values of the Maybe and Either types are no longer compatible with Ramda
  • Nothing() is now known simply as Nothing
  • and and or are now monomorphic
  • xor has been removed
  • meld has been removed
  • flip is now known as flip_
  • C is now known as flip
  • B is now known only as compose
  • S has been removed in favour of ap
  • lift is now known as map
  • match now has a more appropriate type
  • pluck now has prop semantics rather than get semantics
  • get, gets, and parseJson now take predicates rather than type representatives

New exports

  • __ :: Placeholder
  • alt :: Alt f => f a -> f a -> f a
  • ap :: Apply f => f (a -> b) -> f a -> f b
  • apFirst :: Apply f => f a -> f b -> f a
  • apSecond :: Apply f => f a -> f b -> f b
  • bimap :: Bifunctor f => (a -> b) -> (c -> d) -> f a c -> f b d
  • chain :: Chain m => (a -> m b) -> m a -> m b
  • chainRec :: ChainRec m => TypeRep m -> (a -> m (Either a b)) -> a -> m b
  • curry2 :: ((a, b) -> c) -> a -> b -> c
  • curry3 :: ((a, b, c) -> d) -> a -> b -> c -> d
  • curry4 :: ((a, b, c, d) -> e) -> a -> b -> c -> d -> e
  • curry5 :: ((a, b, c, d, e) -> f) -> a -> b -> c -> d -> e -> f
  • empty :: Monoid a => TypeRep a -> a
  • equals :: Setoid a => a -> a -> Boolean
  • extend :: Extend w => (w a -> b) -> w a -> w b
  • extract :: Comonad w => w a -> a
  • filter :: (Applicative f, Foldable f, Monoid (f a)) => (a -> Boolean) -> f a -> f a
  • filterM :: (Monad m, Monoid (m a)) => (a -> Boolean) -> m a -> m a
  • fromEither :: b -> Either a b -> b
  • fromMaybe_ :: (() -> a) -> Maybe a -> a
  • join :: Chain m => m (m a) -> m a
  • joinWith :: String -> Array String -> String
  • matchAll :: GlobalRegExp -> String -> Array { match :: String, groups :: Array (Maybe String) }
  • maybe_ :: (() -> b) -> (a -> b) -> Maybe a -> b
  • mean :: Foldable f => f FiniteNumber -> Maybe FiniteNumber
  • of :: Applicative f => TypeRep f -> a -> f a
  • on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
  • on_ :: ((b, b) -> c) -> (a -> b) -> a -> a -> c
  • promap :: Profunctor p => (a -> b) -> (c -> d) -> p b c -> p a d
  • props :: Accessible a => Array String -> a -> b
  • sequence :: (Applicative f, Traversable t) => TypeRep f -> t (f a) -> f (t a)
  • splitOn :: String -> String -> Array String
  • toEither :: a -> b? -> Either a b
  • toString :: Any -> String
  • traverse :: (Applicative f, Traversable t) => TypeRep f -> (a -> f b) -> t a -> f (t b)
  • zero :: Plus f => TypeRep f -> f a

Change log: sanctuary-js/sanctuary#332
Branch: S_0.12

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.