git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Added some Foldable functions.
3a1c806joneshf
prelude/prelude.purs+32
@@ -342,6 +342,25 @@ module Data.Monoid where
342 mconcat :: forall m. (Monoid m) => [m] -> m
342 mconcat :: forall m. (Monoid m) => [m] -> m
343 mconcat = foldl (<>) mempty
343 mconcat = foldl (<>) mempty
344
344
345+module Control.Applicative where
346+
347+ import Prelude
348+
349+ infixl 4 <*
350+ infixl 4 *>
351+
352+ (<*) :: forall a b f. (Applicative f) => f a -> f b -> f a
353+ (<*) x y = const <$> x <*> y
354+
355+ (*>) :: forall a b f. (Applicative f) => f a -> f b -> f b
356+ (*>) x y = const id <$> x <*> y
357+
358+ lift2 :: forall a b c f. (Applicative f) => (a -> b -> c) -> f a -> f b -> f c
359+ lift2 f x y = f <$> x <*> y
360+
361+ lift3 :: forall a b c d f. (Applicative f) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
362+ lift3 f x y z = f <$> x <*> y <*> z
363+
345module Control.Monad where
364module Control.Monad where
346
365
347 import Prelude
366 import Prelude
@@ -1227,6 +1246,7 @@ module Text.Parsing.Read where
1227module Data.Foldable where
1246module Data.Foldable where
1228
1247
1229 import Prelude
1248 import Prelude
1249+ import Control.Applicative
1230 import Data.Either
1250 import Data.Either
1231 import Data.Eq
1251 import Data.Eq
1232 import Data.Maybe
1252 import Data.Maybe
@@ -1281,3 +1301,15 @@ module Data.Foldable where
1281 foldl f z (Tuple _ x) = z `f` x
1301 foldl f z (Tuple _ x) = z `f` x
1282
1302
1283 foldMap f (Tuple _ x) = f x
1303 foldMap f (Tuple _ x) = f x
1304+
1305+ fold :: forall f m. (Foldable f, Monoid m) => f m -> m
1306+ fold = foldMap id
1307+
1308+ traverse_ :: forall a b f m. (Applicative m, Foldable f) => (a -> m b) -> f a -> m {}
1309+ traverse_ f = foldr ((*>) <<< f) (pure {})
1310+
1311+ for_ :: forall a b f m. (Applicative m, Foldable f) => f a -> (a -> m b) -> m {}
1312+ for_ = flip traverse_
1313+
1314+ sequence_ :: forall a f m. (Applicative m, Foldable f) => f (m a) -> m {}
1315+ sequence_ = traverse_ id