Search results
map :: forall f a b. Functor f => (a -> b) -> f a -> f b
Map k v
represents maps from keys of type k
to values of type v
.
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.
mapEnv :: forall e a b. (a -> b) -> Env e a -> Env e b
Change the data type in an Env
computation.
mapRWS :: forall r w1 w2 s a1 a2. (RWSResult s a1 w1 -> RWSResult s a2 w2) -> RWS r w1 s a1 -> RWS r w2 s a2
Change the types of the result and accumulator in a RWS
action
mapCont :: forall r a. (r -> r) -> Cont r a -> Cont r a
Transform the result of a continuation-passing function.
mapEnvT :: forall e w1 w2 a b. (w1 a -> w2 b) -> EnvT e w1 a -> EnvT e w2 b
Change the underlying comonad and data type in an EnvT
context.
mapRWST :: forall r w1 w2 s m1 m2 a1 a2. (m1 (RWSResult s a1 w1) -> m2 (RWSResult s a2 w2)) -> RWST r w1 s m1 a1 -> RWST r w2 s m2 a2
Change the result and accumulator types in a RWST
monad action.
mapping :: forall a b f. Mapping f a b => f -> a -> b
mapping :: forall s t a b f g. Functor f => Functor g => AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
mapMaybe :: forall a b. (a -> Maybe b) -> List a -> List b
Apply a function to each element in a list, keeping only the results which contain a value.
Running time: O(n)
mapMaybe :: forall a b. (a -> Maybe b) -> List a -> List b
Apply a function to each element in a list, keeping only the results which contain a value.
Running time: O(n)
mapMaybe :: forall a b. (a -> Maybe b) -> NonEmptyList a -> List b
mapMaybe :: forall a b. (a -> Maybe b) -> Array a -> Array b
Apply a function to each element in an array, keeping only the results which contain a value, creating a new array.
parseEmail :: String -> Maybe Email
parseEmail = ...
mapMaybe parseEmail ["a.com", "hello@example.com", "--"]
= [Email {user: "hello", domain: "example.com"}]
mapMaybe :: forall a b. (a -> Maybe b) -> NonEmptyArray a -> Array b
mapMaybe :: forall k a b. Ord k => (a -> Maybe b) -> Map k a -> Map k b
Applies a function to each value in a map, discarding entries where the
function returns Nothing
.
mapMaybe :: forall a b. Ord b => (a -> Maybe b) -> Set a -> Set b
Applies a function to each value in a set, discarding entries where the
function returns Nothing
.
mapMaybe :: forall a b. Ord b => (a -> Maybe b) -> NonEmptySet a -> Set b
Applies a function to each value in a set, discarding entries where the
function returns Nothing
.
mapContT :: forall r m a. (m r -> m r) -> ContT r m a -> ContT r m a
Modify the underlying action in a ContT
monad action.
mapMaybe :: forall f a b. Functor f => (a -> Maybe b) -> ListT f a -> ListT f b
Apply a function to the elements of a list, keeping only those return values which contain a result.
mapState :: forall s a b. (Tuple a s -> Tuple b s) -> State s a -> State s b
Change the type of the result in a State
action
mapMaybe :: forall k a b. (a -> Maybe b) -> Map k a -> Map k b
Applies a function to each value in a map, discarding entries where the
function returns Nothing
.
mapReply :: forall state reply mappedReply. (reply -> mappedReply) -> Effect (RestResult reply state) -> Effect (RestResult mappedReply state)
mapAccumL :: forall a b s f. Traversable f => (s -> a -> Accum s b) -> s -> f a -> Accum s (f b)
Fold a data structure from the left, keeping all intermediate results instead of only the final result.
Unlike scanl
, mapAccumL
allows the type of accumulator to differ
from the element type of the final data structure.
mapAccumR :: forall a b s f. Traversable f => (s -> a -> Accum s b) -> s -> f a -> Accum s (f b)
Fold a data structure from the right, keeping all intermediate results instead of only the final result.
Unlike scanr
, mapAccumR
allows the type of accumulator to differ
from the element type of the final data structure.
mapExcept :: forall e e' a b. (Either e a -> Either e' b) -> Except e a -> Except e' b
Transform the unwrapped computation using the given function.
mapMaybeT :: forall m1 m2 a b. (m1 (Maybe a) -> m2 (Maybe b)) -> MaybeT m1 a -> MaybeT m2 b
Change the result type of a MaybeT
monad action.
mapReader :: forall r a b. (a -> b) -> Reader r a -> Reader r b
Change the type of the result in a Reader
monad action.
mapStateT :: forall s m1 m2 a b. (m1 (Tuple a s) -> m2 (Tuple b s)) -> StateT s m1 a -> StateT s m2 b
Change the result type in a StateT
monad action.
mapWriter :: forall w1 w2 a b. (Tuple a w1 -> Tuple b w2) -> Writer w1 a -> Writer w2 b
Change the result and accumulator types in a Writer
monad action
mapFlipped :: forall f a b. Functor f => f a -> (a -> b) -> f b
mapFlipped
is map
with its arguments reversed. For example:
[1, 2, 3] <#> \n -> n * n
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
mapExceptT :: forall e e' m n a b. (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b
Transform the unwrapped computation using the given function.
mapReaderT :: forall r m1 m2 a b. (m1 a -> m2 b) -> ReaderT r m1 a -> ReaderT r m2 b
Change the type of the result in a ReaderT
monad action.
mapWriterT :: forall w1 w2 m1 m2 a b. (m1 (Tuple a w1) -> m2 (Tuple b w2)) -> WriterT w1 m1 a -> WriterT w2 m2 b
Change the accumulator and base monad types in a WriterT
monad action.
mapWithKey :: forall k a b. (k -> a -> b) -> Map k a -> Map k b
mapParserT :: forall b n s a m. (m (Tuple (Either ParseError a) (ParseState s)) -> n (Tuple (Either ParseError b) (ParseState s))) -> ParserT s m a -> ParserT s n b
Change the underlying monad action and data type in a ParserT monad action.
mapWithIndex :: forall f i a b. FunctorWithIndex i f => (i -> a -> b) -> f a -> f b
mapWithIndex :: forall a b. (Int -> a -> b) -> List a -> List b
Apply a function to each element and its index in a list starting at 0.
Deprecated. Use Data.FunctorWithIndex instead.
mapWithIndex :: forall a b. (Int -> a -> b) -> NonEmptyList a -> NonEmptyList b
Apply a function to each element and its index in a list starting at 0.
Deprecated. Use Data.FunctorWithIndex instead.
mapWithIndex :: forall a b. (Int -> a -> b) -> Array a -> Array b
Apply a function to each element in an array, supplying a generated zero-based index integer along with the element, creating an array with the new elements.
prefixIndex index element = show index <> element
mapWithIndex prefixIndex ["Hello", "World"] = ["0Hello", "1World"]
mapWithIndex :: forall a b. (Int -> a -> b) -> NonEmptyArray a -> NonEmptyArray b
mapIdentityT :: forall m1 m2 a b. (m1 a -> m2 b) -> IdentityT m1 a -> IdentityT m2 b
Change the result type of a IdentityT
monad action.
mapMaybeWithKey :: forall k a b. Ord k => (k -> a -> Maybe b) -> Map k a -> Map k b
Applies a function to each key/value pair in a map, discarding entries
where the function returns Nothing
.
mapMaybeWithKey :: forall k a b. (k -> a -> Maybe b) -> Map k a -> Map k b
Applies a function to each key/value pair in a map, discarding entries where the function returns Nothing.