Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Javascript Boolean

Name: Anonymous 2016-09-30 21:51

The Boolean object is an object wrapper for a boolean value.

Syntax

new Boolean([value])

Parameters

value
Optional. The initial value of the Boolean object.

Any object whose value is not undefined or null, including a Boolean object whose value is false, evaluates to true when passed to a conditional statement. For example, the condition in the following if statement evaluates to true:

var x = new Boolean("false");
if (x) {
// this code is executed
}


https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean

Name: Anonymous 2016-10-15 15:42

>>28

Besides that, it also solves it the wrong way. Extending a type with a null object, means that your are adding null as subtype of that type. This wasn't what you wanted, because the problem with null is that it is unwillingly part of every type.

What you actually want is a type, which signals that a computation failed to produce output. This can be a type with two subtypes. One which holds a value and one, which don't:

type Optional a = None | Some a

map : forall a b. (a -> b) -> Optional a -> Optional b
map f (Some a) = Some (f a)
map f None = None


You can use map to lift a function into Optional, if you don't care about the existence of the value inside. Or unwrap it explicitly, if you do care.

Name: Anonymous 2016-10-15 16:37

>>28
Also bullshit.
Argument yourself. Have you read your TAPL today or is your bytefucking brain too small too understand the concept of types?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List