From 6d30175eeb7166b73d888b1b7da5ac6b9fa0db0c Mon Sep 17 00:00:00 2001 From: Jethro Larson Date: Tue, 2 Aug 2022 14:21:55 -0700 Subject: [PATCH] improved definition of pointed functor --- readme.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 1825604..6e2578d 100644 --- a/readme.md +++ b/readme.md @@ -495,14 +495,18 @@ some(1).map(f).map(g) // = some(3) ``` ## Pointed Functor -An object with an `of` function that puts _any_ single value into it. +An object that is a [Functor](#functor) that can be created from _any_ value. A pointed functor can be seen as a container that can wrap something of any type by [lifting](#lift) that value into it. -ES2015 adds `Array.of` making arrays a pointed functor. +Since JS arrays are functors (have a `.map` method) and have an `Array.of()` function they are pointed functors! ```js Array.of(1) // [1] + +Array.of(1).map(add(1)) // [2] ``` +This `of` function is an important requirement for satisfying the [Monad](#monad) interface where it is an example of a [Kleisli Arrow](#kleisi-composition). + ## Lift Lifting is when you take a value and put it into an object like a [functor](#pointed-functor). If you lift a function into an [Applicative Functor](#applicative-functor) then you can make it work on values that are also in that functor.