Search results

liftA1 :: forall f a b. Applicative f => (a -> b) -> f a -> f b

liftA1 provides a default implementation of (<$>) for any Applicative functor, without using (<$>) as provided by the Functor-Applicative superclass relationship.

liftA1 can therefore be used to write Functor instances as follows:

instance functorF :: Functor F where
  map = liftA1
liftM1 :: forall m a b. Monad m => (a -> b) -> m a -> m b

liftM1 provides a default implementation of (<$>) for any Monad, without using (<$>) as provided by the Functor-Monad superclass relationship.

liftM1 can therefore be used to write Functor instances as follows:

instance functorF :: Functor F where
  map = liftM1
map :: forall f a b. Functor f => (a -> b) -> f a -> f b
mapDefault :: forall i f a b. FunctorWithIndex i f => (a -> b) -> f a -> f b

A default implementation of Functor's map in terms of mapWithIndex

squigglyMap :: forall f a b. Functor f => (a -> b) -> f a -> f b
map :: forall p q a b. Dissect p q => (a -> b) -> p a -> p b

A tail-recursive map operation, implemented in terms of Dissect.

map :: forall a c b. HasMap a => (b -> c) -> a b -> a c
map :: forall f a b. Functor f => (a -> b) -> f a -> f b
map :: forall a b. Ord b => (a -> b) -> Set a -> Set b

Maps over the values in a set.

This operation is not structure-preserving for sets, so is not a valid Functor. An example case: mapping const x over a set with n > 0 elements will result in a set with one element.

map :: forall a b. Ord b => (a -> b) -> NonEmptySet a -> NonEmptySet b

Maps over the values in a set.

This operation is not structure-preserving for sets, so is not a valid Functor. An example case: mapping const x over a set with n > 0 elements will result in a set with one element.

map :: forall a b. Hashable b => (a -> b) -> HashSet a -> HashSet b

Construct a new set by applying a function to each element of an input set.

If distinct inputs map to the same output, this changes the cardinality of the set, therefore hash set is not a Functor. Also, the order in which elements appear in the new set is entirely dependent on the hash function for type b.

withUor :: forall a b. (a -> b) -> UndefinedOr a -> UndefinedOr b
pseudoMap :: forall a b. (a -> b) -> Opt a -> Opt b
mapEvent :: forall b a. (a -> b) -> HTML a -> HTML b

Map HTML with event type a to HTML with event type b.

It's important that memoize is only used at a top-level declaration – not inside a view. This is because PureScript is eagerly evaluated like JavaScript. If memoize is used inside a view it will recreate the memoized function every time the view is called.

map :: forall a b. Ord b => (a -> b) -> OSet a -> OSet b

Maps over the values in a set.

This operation is not structure-preserving for sets, so is not a valid Functor. An example case: mapping const x over a set with n > 0 elements will result in a set with one element.

map :: forall a b. (a -> b) -> Seq a -> Seq b

O(n). Apply a function to every element within a sequence. Note that this function is performed lazily — the actual call is almost instantaneous, regardless of the length of the sequence, because the function is not applied to all elements immediately. The eventual running time (assuming all elements are later requested) is O(n), though.

map :: forall b a. NotJSPromise b => (a -> b) -> PromiseSpec a -> PromiseSpec b

map the value in a promise spec

map :: forall b a. Hashable b => (a -> b) -> MultiSet a -> MultiSet b
extent' :: forall m d. Magnitude m => (d -> m) -> Array d -> Array m
fmap :: forall b a. (a -> b) -> Event a -> Event b
map :: forall b a. (a -> b) -> List a -> List b
map :: forall msgA msgB. (msgA -> msgB) -> Document msgA -> Document msgB
mapChange :: forall c d. (c -> d) -> Change c -> Change d

Transform a Change by applying a function to both old and new values.

mapImpl :: forall a b. (a -> b) -> AffList a -> AffList b
mapNullable :: forall b a. NeverNull b => (a -> b) -> Nullable a -> Nullable b

Change the value inside a Nullable using a function.

mMap :: forall a b. (a -> b) -> Music a -> Music b
pMap :: forall a b. (a -> b) -> Primitive a -> Primitive b
smap :: forall b a. (a -> b) -> Slice a -> Slice b

Apply a function to each element in a slice, creating a new slice.

smap :: forall b a. (a -> b) -> Slice a -> Slice b

Apply a function to each element in a slice, creating a new slice.

uop :: forall a b. (a -> b) -> AudioParameter_ a -> AudioParameter_ b
updateBody :: forall a b. (a -> b) -> Response a -> Response b
map :: forall b a. (a -> b) -> SortedArray a -> Array b

Functor-like convenience function, equivalent to unwrapping and applying the Array map.

s_fmap :: forall b a. (a -> b) -> Signal a -> SigBuilder b
shouldNotSatisfyM_Flipped :: forall m a. MonadThrow Error m => Show a => (a -> Boolean) -> m a -> m Unit
shouldSatisfyM_Flipped :: forall m a. MonadThrow Error m => Show a => (a -> Boolean) -> m a -> m Unit
use1 :: forall a x. (a -> x) -> (Case1 a -> F x)
mapRecord :: forall a b rin rout. HFoldlWithIndex (MapRecord a b) (Builder (Record ()) (Record ())) (Record rin) (Builder (Record ()) (Record rout)) => (a -> b) -> Record rin -> Record rout

Recursively maps a record using a function f.

let
  f :: Int -> String
  f i = show (i + 1)
mapRecord  f { a : { b : 10, c : { d: 20, e : Just "hello" }}, f : 30 }
-- { a : { b : "11", c : { d: "21", e : Just "hello" }, f : "31" }
mapUniformRecord :: forall row xs a b row'. RowToList row xs => MapUniformRecord xs row a b () row' => (a -> b) -> Record row -> Record row'
mapRecord :: forall row xs a b row'. RowToList row xs => MapRecord xs row a b () row' => (a -> b) -> Record row -> Record row'
alter' :: forall a b. (a -> b /\ (Array (Tree b))) -> Tree a -> Tree b

Traverse the nodes of given tree with the function, building a new tree with updated values and children |

defaultFilter :: forall a h f. BooleanEq h => Applicative f => Foldable f => Monoid (f a) => (a -> h) -> f a -> f a
filter :: forall f h a. Filterable f => BooleanEq h => (a -> h) -> f a -> f a
mapRecord :: forall a b rin rout. HFoldlWithIndex (MapRecord a b) (Builder (Record ()) (Record ())) (Record rin) (Builder (Record ()) (Record rout)) => (a -> b) -> Record rin -> Record rout

Recursively maps a record using a function f.

let
  f :: Int -> String
  f i = show (i + 1)
mapRecord  f { a : { b : 10, c : { d: 20, e : Just "hello" }}, f : 30 }
-- { a : { b : "11", c : { d: "21", e : Just "hello" }, f : "31" }
mapRecord :: forall row rowList a b row'. RowToList row rowList => MapRecord rowList row a b () row' => (a -> b) -> Record row -> Record row'
modifyNodeValue :: forall a. (a -> a) -> Tree a -> Tree a

Modify the value of a node.

modifyValue :: forall a. (a -> a) -> Loc a -> Loc a

Modify the value of the current Node.

filter :: forall f a. Filterable f => (a -> Boolean) -> f a -> f a
filterDefault :: forall f a. Filterable f => (a -> Boolean) -> f a -> f a

A default implementation of filter using filterMap.

filterDefaultPartition :: forall f a. Filterable f => (a -> Boolean) -> f a -> f a

A default implementation of filter using partition.

filterDefaultPartitionMap :: forall f a. Filterable f => (a -> Boolean) -> f a -> f a

A default implementation of filter using partitionMap.

modify :: forall m s. MonadEffect m => (s -> s) -> Ref s -> m s
iterateUntil :: forall m a. Monad m => (a -> Boolean) -> m a -> m a

Execute an action repeatedly until its result satisfies a predicate, and return that result (discarding all others).

iterateUntil :: forall m a. MonadRec m => (a -> Boolean) -> m a -> m a

Execute an action repeatedly until its result satisfies a predicate, and return that result (discarding all others).

iterateWhile :: forall m a. Monad m => (a -> Boolean) -> m a -> m a

Execute an action repeatedly until its result fails to satisfy a predicate, and return that result (discarding all others).

iterateWhile :: forall m a. MonadRec m => (a -> Boolean) -> m a -> m a

Execute an action repeatedly until its result fails to satisfy a predicate, and return that result (discarding all others).

modify :: forall b. (b -> b) -> Buffer b -> Buffer b
modifyNodeValue :: forall a. (a -> a) -> Tree a -> Tree a

Modify the value of a node.

modifyValue :: forall a. (a -> a) -> Loc a -> Loc a

Modify the value of the current Node.

retryUntil :: forall m a. Monad m => (a -> Boolean) -> m a -> m a

Repeat a computation until the value satisfies a predicate

update :: forall n. (n -> n) -> Tree n -> Tree n

Update value of the tree node using its current value. |

findEachIndex :: forall a. (a -> Boolean) -> Array a -> Array Int
modifyAndRead :: forall m s. MonadEffect m => (s -> s) -> Ref s -> m s
dropWhile :: forall f a. Container f => (a -> Boolean) -> f a -> f a
filter :: forall a b. HasFilter a => (b -> Boolean) -> a b -> a b
findAllIndices :: forall a. (a -> Boolean) -> List a -> List Int
findIndex :: forall f a. Container f => (a -> Boolean) -> f a -> Maybe Int
findIndices :: forall a. (a -> Boolean) -> Array a -> Array Int

Find the all the indices for which a predicate holds.

findIndices (contains $ Pattern "b") ["a", "bb", "b", "d"] = [1, 2]
findIndices (contains $ Pattern "x") ["a", "bb", "b", "d"] = []
modifyCurrent :: forall a. (a -> a) -> ZipperArray a -> ZipperArray a
modifyFocus :: forall a. (a -> a) -> ArrayZipper a -> ArrayZipper a

Uses a function to update the focus element. O(n)

modifyNodeValue :: forall a. (a -> a) -> Tree a -> Tree a

Modify the value of a node.

modifyRef :: forall s m. MonadEffect m => (s -> s) -> Ref s -> m s
modifyValue :: forall a. (a -> a) -> Loc a -> Loc a

Modify the value of the current Node.

modifyX :: forall a. (a -> a) -> Vec a -> Vec a

Modifies the X component of a vector

> modifyX (add 10) (Vec 3 4)
Vec 13 4
modifyX :: forall a. (a -> a) -> Vec a -> Vec a

Modifies the X component of a vector

> modifyX (add 10) (Vec 3 4 2)
Vec 13 4 2
modifyY :: forall a. (a -> a) -> Vec a -> Vec a

Modifies the Y component of a vector

> modifyY (add 10) (Vec 3 4)
Vec 3 14
modifyY :: forall a. (a -> a) -> Vec a -> Vec a

Modifies the Y component of a vector

> modifyY (add 10) (Vec 3 4 2)
Vec 3 14 2
modifyZ :: forall a. (a -> a) -> Vec a -> Vec a

Modifies the Z component of a vector

> modifyZ (add 10) (Vec 3 4 2)
Vec 3 4 20
modParam :: forall a. (a -> a) -> AudioParameter_ a -> AudioParameter_ a
until :: forall a m. Monad m => (a -> Boolean) -> m a -> m a
findIndex :: forall a. (a -> Boolean) -> Array a -> Maybe Int

Find the first index for which a predicate holds.

findIndex (contains $ Pattern "b") ["a", "bb", "b", "d"] = Just 1
findIndex (contains $ Pattern "x") ["a", "bb", "b", "d"] = Nothing
findIndex :: forall a. (a -> Boolean) -> NonEmptyArray a -> Maybe Int
findLastIndex :: forall a. (a -> Boolean) -> Array a -> Maybe Int

Find the last index for which a predicate holds.

findLastIndex (contains $ Pattern "b") ["a", "bb", "b", "d"] = Just 2
findLastIndex (contains $ Pattern "x") ["a", "bb", "b", "d"] = Nothing
findLastIndex :: forall a. (a -> Boolean) -> NonEmptyArray a -> Maybe Int
sortWith :: forall a b. Ord b => (a -> b) -> Array a -> Array a

Sort the elements of an array in increasing order, where elements are sorted based on a projection. Sorting is stable: the order of elements is preserved if they are equal according to the projection.

sortWith (_.age) [{name: "Alice", age: 42}, {name: "Bob", age: 21}]
   = [{name: "Bob", age: 21}, {name: "Alice", age: 42}]
sortWith :: forall a b. Ord b => (a -> b) -> NonEmptyArray a -> NonEmptyArray a
modify :: forall s. (s -> s) -> Ref s -> Effect s

Update the value of a mutable reference by applying a function to the current value. The updated value is returned.

findIndex :: forall a. (a -> Boolean) -> List a -> Maybe Int

Find the first index for which a predicate holds.

findIndex :: forall a. (a -> Boolean) -> List a -> Maybe Int

Find the first index for which a predicate holds.

findIndex :: forall a. (a -> Boolean) -> NonEmptyList a -> Maybe Int
findLastIndex :: forall a. (a -> Boolean) -> List a -> Maybe Int

Find the last index for which a predicate holds.

findLastIndex :: forall a. (a -> Boolean) -> List a -> Maybe Int

Find the last index for which a predicate holds.

findLastIndex :: forall a. (a -> Boolean) -> NonEmptyList a -> Maybe Int
all :: forall a t. TypedArray a t => (t -> Boolean) -> ArrayView a -> Effect Boolean

Test a predicate to pass on all values.

any :: forall a t. TypedArray a t => (t -> Boolean) -> ArrayView a -> Effect Boolean

Test a predicate to pass on any value.

findIndex :: forall a. (a -> Boolean) -> OSet a -> Maybe Int
findLastIndex :: forall a. (a -> Boolean) -> OSet a -> Maybe Int
sortWith :: forall a b. Ord b => (a -> b) -> OSet a -> OSet a
findIndex :: forall a. (a -> Boolean) -> TwoOrMore a -> Maybe Int
withContext' :: forall ctx props. (props -> ctx) -> ReactClass props -> ReactClass props
findBy :: forall a. (a -> Boolean) -> Play a -> Maybe (ItemPath /\ (Play a))

Find the first sub-layout in the layout tree in the layout tree that satisfies the given predicate. Returns Nothing if no such item exists. The returned value includes both the path to the item and the item itself. Root is at path [].