Skip to content

Commit

Permalink
Add pipeline utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hojberg committed Aug 13, 2024
1 parent f2da08f commit d2c3486
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Lib/Util.elm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ decodeFailInvalid failMessage m =
Decode.succeed a


pipeMaybe : (b -> a -> a) -> Maybe b -> a -> a
pipeMaybe f may a =
case may of
Just b ->
f b a

Nothing ->
a


pipeIf : (a -> a) -> Bool -> a -> a
pipeIf f cond a =
if cond then
f a

else
a


decodeTag : Decode.Decoder String
decodeTag =
Decode.field "tag" Decode.string
Expand Down

0 comments on commit d2c3486

Please sign in to comment.