git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Added some Foldable functions.
commit3a1c806dd4528dd3521a212f94c390224f964741 authorjoneshf <jones3.hardy@gmail.com> dateSun 9 Mar 2014, 22:07 (13 years ago) parent4c16a28
1 file changed+32
prelude/prelude.purs+32
prelude/prelude.purs+32
@@ -342,6 +342,25 @@ module Data.Monoid where
342342 mconcat :: forall m. (Monoid m) => [m] -> m
343343 mconcat = foldl (<>) mempty
344344
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+
345364module Control.Monad where
346365
347366 import Prelude
@@ -1227,6 +1246,7 @@ module Text.Parsing.Read where
12271246module Data.Foldable where
12281247
12291248 import Prelude
1249+ import Control.Applicative
12301250 import Data.Either
12311251 import Data.Eq
12321252 import Data.Maybe
@@ -1281,3 +1301,15 @@ module Data.Foldable where
12811301 foldl f z (Tuple _ x) = z `f` x
12821302
12831303 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