Add mwhen
This commit is contained in:
parent
41f0b8d511
commit
d18166951b
@ -39,6 +39,7 @@ module Pre (
|
||||
module Text.Megaparsec.Char.Lexer,
|
||||
module Text.Pretty.Simple,
|
||||
Puzzle (..),
|
||||
mwhen,
|
||||
(<<$>>),
|
||||
(<<&>>),
|
||||
takeUntil,
|
||||
@ -146,6 +147,9 @@ data Puzzle = forall input outputs. (KnownNat (Length outputs), NFData input) =>
|
||||
(<<&>>) :: (Functor f1, Functor f2) => f1 (f2 a) -> (a -> b) -> f1 (f2 b)
|
||||
(<<&>>) = flip (<<$>>)
|
||||
|
||||
mwhen :: (Monoid p) => Bool -> p -> p
|
||||
mwhen b x = if b then x else mempty
|
||||
|
||||
takeUntil :: (Foldable t) => (a -> Bool) -> t a -> [a]
|
||||
takeUntil p = foldr (\x xs -> x : if p x then [] else xs) []
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user