File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 4343
4444 for_ :: forall a b f m. (Applicative m, Foldable f) => f a -> (a -> m b) -> m Unit
4545
46+ intercalate :: forall f m. (Foldable f, Monoid m) => m -> f m -> m
47+
4648 lookup :: forall a b f. (Eq a, Foldable f) => a -> f (Tuple a b) -> Maybe b
4749
4850 mconcat :: forall f m. (Foldable f, Monoid m) => f m -> m
Original file line number Diff line number Diff line change @@ -70,6 +70,12 @@ sequence_ = traverse_ id
7070mconcat :: forall f m . (Foldable f , Monoid m ) => f m -> m
7171mconcat = foldl (<>) mempty
7272
73+ intercalate :: forall f m . (Foldable f , Monoid m ) => m -> f m -> m
74+ intercalate sep xs = (foldl go { init: true , acc: mempty } xs).acc
75+ where
76+ go { init = true } x = { init: false , acc: x }
77+ go { acc = acc } x = { init: false , acc: acc <> sep <> x }
78+
7379and :: forall f . (Foldable f ) => f Boolean -> Boolean
7480and = foldl (&&) true
7581
@@ -98,7 +104,7 @@ find :: forall a f. (Foldable f) => (a -> Boolean) -> f a -> Maybe a
98104find p f = case foldMap (\x -> if p x then [x] else [] ) f of
99105 (x:_) -> Just x
100106 [] -> Nothing
101-
107+
102108lookup :: forall a b f . (Eq a , Foldable f ) => a -> f (Tuple a b ) -> Maybe b
103109lookup a f = runFirst $ foldMap (\(Tuple a' b) -> First (if a == a' then Just b else Nothing )) f
104110
You can’t perform that action at this time.
0 commit comments