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 [].
findByInLayout :: forall a. (a -> Boolean) -> Layout a -> Maybe (ItemPath /\ (Tree (WithRect 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 [].
modify :: forall s. (s -> s) -> BehaviorRef s -> Effect s
_splitByBreak' :: (Words -> Doc) -> Array Words -> Array Doc
findIndex :: forall a. (a -> Boolean) -> ArrayView a -> Maybe Int
findIndex :: forall a. (a -> Boolean) -> NonEmptyArrayView a -> Maybe Int
findIndex :: forall a. (a -> Boolean) -> List a -> Maybe Int
Find the first index for which a predicate holds.
findLastIndex :: forall a. (a -> Boolean) -> ArrayView a -> Maybe Int
findLastIndex :: forall a. (a -> Boolean) -> NonEmptyArrayView a -> Maybe Int
findLastIndex :: forall a. (a -> Boolean) -> List a -> Maybe Int
Find the last index for which a predicate holds.
mapIndex :: forall row rowList a b row'. RowToList row rowList => MapIndex rowList row a b () row' => (String -> b) -> Proxy row -> Record row'
sortOn :: forall a b. Ord b => (a -> b) -> Array a -> Array a
Sort a list by a projection.
sortOn (\x -> if x == "dog" then 2 else 1) ["apple", "dog", "kiwi"] = ["apple", "kiwi", "dog"]
sortOn' :: forall a b. Ord b => (a -> b) -> Array a -> Array a
Sort a list by a projection.
This version of sortOn uses the decorate-sort-undecorate paradigm or Schwartzian transform. Which means the projection for each entry will only be computed once at the cost of creating more data structures. You will have to benchmark your specific situation to find out whether sortOn or sortOn' is faster.
sortOn' (\x -> if x == "dog" then 2 else 1) ["apple", "dog", "kiwi"] = ["apple", "kiwi", "dog"]
sortWith :: forall b a. Ord b => (a -> b) -> ArrayView a -> ArrayView a
sortWith :: forall b a. Ord b => (a -> b) -> NonEmptyArrayView a -> NonEmptyArrayView a
sortWith :: forall b a. Ord b => (a -> b) -> List a -> List a
Sort the elements of a list in increasing order, where elements are sorted based on a projection
Running time: O(n*log(n)).
find :: forall a f. Foldable f => (a -> Boolean) -> f a -> Maybe a
Try to find an element in a data structure which satisfies a predicate.
dropWhile :: forall a. (a -> Boolean) -> Array a -> Array a
Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new array.
dropWhile (_ < 0) [-3, -1, 0, 4, -6] = [0, 4, -6]
filter :: forall a. (a -> Boolean) -> Array a -> Array a
Filter an array, keeping the elements which satisfy a predicate function, creating a new array.
filter (_ > 0) [-1, 4, -5, 7] = [4, 7]
takeWhile :: forall a. (a -> Boolean) -> Array a -> Array a
Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new array.
takeWhile (_ > 0) [4, 1, 0, -4, 5] = [4, 1]
takeWhile (_ > 0) [-1, 4] = []
dropWhile :: forall a. (a -> Boolean) -> List a -> List a
Drop those elements from the front of a list which match a predicate.
Running time (worst case): O(n)
dropWhile :: forall a. (a -> Boolean) -> List a -> List a
Drop those elements from the front of a list which match a predicate.
Running time (worst case): O(n)
filter :: forall a. (a -> Boolean) -> List a -> List a
Filter a list, keeping the elements which satisfy a predicate function.
Running time: O(n)
filter :: forall a. (a -> Boolean) -> List a -> List a
Filter a list, keeping the elements which satisfy a predicate function.
Running time: O(n)
takeWhile :: forall a. (a -> Boolean) -> List a -> List a
Take those elements from the front of a list which match a predicate.
Running time (worst case): O(n)
takeWhile :: forall a. (a -> Boolean) -> List a -> List a
Take those elements from the front of a list which match a predicate.
Running time (worst case): O(n)
filter :: forall a. Ord a => (a -> Boolean) -> Set a -> Set a
Filter out those values of a set for which a predicate on the value fails to hold.
filter :: forall a. (a -> Boolean) -> Object a -> Object a
Filter out those key/value pairs of a map for which a predicate on the value fails to hold.
filter :: forall a. (a -> Boolean) -> Emitter a -> Emitter a
Create an Emitter which only fires when a predicate holds.
modify_ :: forall m s. MonadEffect m => (s -> s) -> Ref s -> m Unit
filter :: forall a. (a -> Boolean) -> HashSet a -> HashSet a
Remove all elements from the set for which the predicate does not hold.
filter (const false) s == empty
derivative :: forall a. Eq a => Semiring a => (Int -> a) -> Polynomial a -> Polynomial a
dropWhileExcl :: forall a. (a -> Boolean) -> Array a -> Array a
dropWhileIncl :: forall a. (a -> Boolean) -> Array a -> Array a
reject :: forall a. (a -> Boolean) -> Array a -> Array a
takeWhileExcl :: forall a. (a -> Boolean) -> Array a -> Array a
takeWhileIncl :: forall a. (a -> Boolean) -> Array a -> Array a
deleteWith :: forall a. (a -> Boolean) -> OSet a -> OSet a
Delete first element matching the predicate.
dropWhile :: forall a. (a -> Boolean) -> OSet a -> OSet a
filter :: forall a. (a -> Boolean) -> OSet a -> OSet a
filter :: forall a. (a -> Boolean) -> Seq a -> Seq a
O(n). Create a new Seq which contains only those elements of the input Seq which satisfy the given predicate.
filter :: forall a. (a -> Boolean) -> Seq a -> Seq a
O(n). Create a new (possibly empty) sequence which contains only those elements of the input sequence which satisfy the given predicate.
filter :: forall a. (a -> Boolean) -> Vector a -> Vector a
reject :: forall a. (a -> Boolean) -> Vector a -> Vector a
takeWhile :: forall a. (a -> Boolean) -> OSet a -> OSet a
filter :: forall a. (a -> Boolean) -> Stream a -> Stream a
Filter a stream, keeping the elements which satisfy a predicate function, creating a new stream.
Semantically.
filter p s = filter (\(time, a) -> p x) s
filter :: forall a. (a -> Boolean) -> MultiSet a -> MultiSet a
filter :: forall a. (a -> Boolean) -> Stream a -> Stream a
modify :: forall m s. MonadEffect m => (s -> s) -> Ref s -> m Unit
withFilter :: forall node. (node -> Boolean) -> ForceConfig node -> ForceConfig node
Add a filter predicate (force only applies to matching nodes)
withFilter :: forall node. (node -> Boolean) -> ForceConfig node -> ForceConfig node
Add a filter predicate (force only applies to matching nodes)