Module

Neon.Primitive

Package
purescript-neon
Repository
tfausak/purescript-neon

Functions that operate on primitve data types. Note that not all data types are represented. That's either because there's no actions you can take on them in general (like Objects) or because the actions are in type classes instead (for Arrays).

Re-exports from Neon.Primitive.Char

#toUpper Source

toUpper :: Char -> Char

Converts a character to upper case.

toUpper 'a' -- 'A'
toUpper 'A' -- 'A'

#toString Source

toString :: Char -> String

Converts a character into a string.

toString 'a' -- "a"

#toLower Source

toLower :: Char -> Char

Converts a character to lower case.

toLower 'A' -- 'a'
toLower 'a' -- 'a'

Re-exports from Neon.Primitive.Function

#identity Source

identity :: forall a. a -> a

Returns the value it was given.

identity 1 -- 1

This is the identity function.

#flip Source

flip :: forall c b a. (a -> b -> c) -> (b -> a -> c)

Flips the first two arguments of a function.

"a" :add "b" -- "ab"
"a" :flip add "b" -- "ba"

#compose Source

compose :: forall c b a. (b -> c) -> (a -> b) -> (a -> c)

Returns a new function that calls the first function with the result of calling the second.

let addTwo x = x + 2
let double x = x * 2
let addTwoThenDouble x = addTwo :compose double
addTwoThenDouble 3 -- 10

This is function composition.

#always Source

always :: forall b a. a -> b -> a

Always returns the first argument.

"anything" :always 1 -- 1

This is the constant function.

Re-exports from Neon.Primitive.Int

#toNumber Source

toNumber :: Int -> Number

Converts an integer into a number.

toNumber 1 -- 1.0

Re-exports from Neon.Primitive.Number

#round Source

round :: Number -> Int

Rounds a number to the nearest integer.

round 1.4 -- 1
round 1.6 -- 2
round 1.5 -- 2
round 2.5 -- 3

#nan Source

nan :: Number

An alias for NaN from JavaScript.

#infinity Source

infinity :: Number

An alias for Infinity from JavaScript.

#floor Source

floor :: Number -> Int

Rounds a number down.

floor 1.9 -- 1

#finite Source

finite :: Number -> Boolean

Tests whether a number is finite or not.

finite 1.0 -- true
finite infinity -- false

#ceiling Source

ceiling :: Number -> Int

Rounds a number up.

ceiling 1.1 -- 2

#aNumber Source

aNumber :: Number -> Boolean

Tests if a number is a valid number. Returns false if the number is nan. This is necessary because nan does not equal itself.

aNumber 1.0 -- true
aNumber nan -- false
nan == nan -- false