Each is not void, it returns a parameter of type A[]

This commit is contained in:
Haskell Camargo
2015-06-14 23:21:47 -03:00
parent 9796c3973d
commit f9c3edf6c6
2 changed files with 14 additions and 8 deletions
+10 -6
View File
@@ -1,23 +1,27 @@
/// <reference path="./prelude-ls.d.ts" />
import prelude = require("prelude-ls");
prelude.id(5); //=> 5
prelude.id({}); //=> {}
var five: number = prelude.id(5); //=> 5
var emptyObj: Object = prelude.id({}); //=> {}
prelude.isType("Undefined", void 8); //=> true
var expectBool: boolean = prelude.isType("Undefined", void 8); //=> true
prelude.isType("Boolean", true); //=> true
prelude.isType("Number", 1); //=> true
prelude.isType("String", "hi"); //=> true
prelude.isType("Object", {}); //=> true
prelude.isType("Array", []); //=> true
prelude.replicate(4, 3); //=> [3, 3, 3, 3]
prelude.replicate(4, "a"); //=> ["a", "a", "a", "a"]
var numberArray: Array<number> = prelude.replicate(4, 3); //=> [3, 3, 3, 3]
var strArray: Array<string> =
prelude.replicate(4, "a"); //=> ["a", "a", "a", "a"]
prelude.replicate(0, "a"); //=> []
// List
prelude.each(x => x.push("boom"), [["a"], ["b"], ["c"]]);
var dblStrArray: Array<Array<string>> =
prelude.each(x => x.push("boom"), [["a"], ["b"], ["c"]]);
//=> [["a", "boom"], ["b", "boom"], ["c", "boom"]]
prelude.map(x => x * 2, [1, 2, 3, 4, 5]); //=> [2, 4, 6, 8, 10]
+4 -2
View File
@@ -3,6 +3,8 @@
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Change [0]: 2015/06/14 - Marcelo Camargo <https://github.com/haskellcamargo>
declare module "prelude-ls" {
module PreludeLS {
export function id<A>(x: A): A;
@@ -14,8 +16,8 @@ declare module "prelude-ls" {
// List
export function each<A>(f: (x: A) => void): (xs: A[]) => void;
export function each<A>(f: (x: A) => void, xs: A[]): void;
export function each<A>(f: (x: A) => void): (xs: A[]) => A[];
export function each<A>(f: (x: A) => void, xs: A[]): A[];
export function map<A, B>(f: (x: A) => B): (xs: A[]) => B[];
export function map<A, B>(f: (x: A) => B, xs: A[]): B[];
export function compact<A>(xs: A[]): A[];