feat(users/Profpatsch/whatcd-resolver): trace http requests
Move the http calls into their own module, so we can trace the request and provide a simple copy-to-replay command. We have to work around a bug in the otel library, which would limit our attribute value length to 128 bytes because it uses the wrong option value. ~~~ `ifExists` is finally made more useful for dealing with optional attributes in e.g. lists. Change-Id: Iafab523e9ec4b00136db43f31fdc12aeefb7f77c Reviewed-on: https://cl.tvl.fyi/c/depot/+/11241 Tested-by: BuildkiteCI Autosubmit: Profpatsch <mail@profpatsch.de> Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
parent
0b78998509
commit
eeb5e7abd6
10 changed files with 201 additions and 42 deletions
|
|
@ -757,25 +757,19 @@ mapFromListOnMerge f xs =
|
|||
ifTrue :: (Monoid m) => Bool -> m -> m
|
||||
ifTrue pred' m = if pred' then m else mempty
|
||||
|
||||
-- | If the given @Maybe@ is @Just@, return the @m@, else return mempty.
|
||||
-- | If the given @Maybe@ is @Just@, return the result of `f` wrapped in `pure`, else return `mempty`.
|
||||
|
||||
-- This can be used (together with `ifTrue`) to e.g. create lists with optional elements:
|
||||
--
|
||||
-- >>> import Data.Monoid (Sum(..))
|
||||
--
|
||||
-- >>> :{ mconcat [
|
||||
-- ifExists (Just [1]),
|
||||
-- [2, 3, 4],
|
||||
-- ifExists Nothing,
|
||||
-- ]
|
||||
-- :}
|
||||
-- [1,2,3,4]
|
||||
-- unknown command '{'
|
||||
--
|
||||
-- Or any other Monoid:
|
||||
--
|
||||
-- >>> mconcat [ Sum 1, ifExists (Just (Sum 2)), Sum 3 ]
|
||||
|
||||
-- >>> mconcat [ Sum 1, ifExists id (Just 2), Sum 3 ]
|
||||
-- Sum {getSum = 6}
|
||||
|
||||
ifExists :: (Monoid m) => Maybe m -> m
|
||||
ifExists = fold
|
||||
ifExists :: (Monoid (f b), Applicative f) => (a -> b) -> Maybe a -> f b
|
||||
ifExists f m = m & foldMap @Maybe (pure . f)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue