diff options
author | Profpatsch <mail@profpatsch.de> | 2024-03-03T12·51+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-03-03T13·25+0000 |
commit | c869f9627e19aec255a6c527dcab550d4de5f8e1 (patch) | |
tree | 09ac06233ac51b5c3f9a26298cc198e83c96d79e /users/Profpatsch/my-webstuff | |
parent | 5a086020cbe09784852f231803cd47bc96de5b75 (diff) |
chore(users/Profpatsch): misc small improvements r/7636
Change-Id: I8fc128391196da22f03bac76a6c621f2cee73334 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11084 Autosubmit: Profpatsch <mail@profpatsch.de> Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
Diffstat (limited to 'users/Profpatsch/my-webstuff')
-rw-r--r-- | users/Profpatsch/my-webstuff/src/Multipart2.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/users/Profpatsch/my-webstuff/src/Multipart2.hs b/users/Profpatsch/my-webstuff/src/Multipart2.hs index 17246546ab35..5c283a3c1be8 100644 --- a/users/Profpatsch/my-webstuff/src/Multipart2.hs +++ b/users/Profpatsch/my-webstuff/src/Multipart2.hs @@ -108,7 +108,7 @@ parseMultipartOrThrow throwF parser req = do Success a -> pure a -- | Parse the field out of the multipart message -field :: Applicative m => ByteString -> FieldParser ByteString a -> MultipartParseT backend m a +field :: (Applicative m) => ByteString -> FieldParser ByteString a -> MultipartParseT backend m a field fieldName fieldParser = MultipartParseT $ \mp -> mp.inputs & findMaybe (\input -> if fst input == fieldName then Just (snd input) else Nothing) @@ -118,7 +118,7 @@ field fieldName fieldParser = MultipartParseT $ \mp -> & pure -- | Parse the field out of the multipart message -field' :: Applicative m => ByteString -> FieldParser ByteString a -> MultipartParseT backend m (FormValidation a) +field' :: (Applicative m) => ByteString -> FieldParser ByteString a -> MultipartParseT backend m (FormValidation a) field' fieldName fieldParser = MultipartParseT $ \mp -> mp.inputs & findMaybe (\input -> if fst input == fieldName then Just $ snd input else Nothing) @@ -136,15 +136,15 @@ field' fieldName fieldParser = MultipartParseT $ \mp -> & pure -- | Parse the field out of the multipart message, and into a 'Label' of the given name. -fieldLabel :: forall lbl backend m a. Applicative m => ByteString -> FieldParser ByteString a -> MultipartParseT backend m (Label lbl a) +fieldLabel :: forall lbl backend m a. (Applicative m) => ByteString -> FieldParser ByteString a -> MultipartParseT backend m (Label lbl a) fieldLabel fieldName fieldParser = label @lbl <$> field fieldName fieldParser -- | Parse the field out of the multipart message, and into a 'Label' of the given name. -fieldLabel' :: forall lbl backend m a. Applicative m => ByteString -> FieldParser ByteString a -> MultipartParseT backend m (FormValidation (Label lbl a)) +fieldLabel' :: forall lbl backend m a. (Applicative m) => ByteString -> FieldParser ByteString a -> MultipartParseT backend m (FormValidation (Label lbl a)) fieldLabel' fieldName fieldParser = fmap (label @lbl) <$> field' fieldName fieldParser -- | parse all fields out of the multipart message, with the same parser -allFields :: Applicative m => FieldParser (T2 "key" ByteString "value" ByteString) b -> MultipartParseT backend m [b] +allFields :: (Applicative m) => FieldParser (T2 "key" ByteString "value" ByteString) b -> MultipartParseT backend m [b] allFields fieldParser = MultipartParseT $ \mp -> mp.inputs <&> tupToT2 @"key" @"value" @@ -157,7 +157,7 @@ tupToT2 (a, b) = T2 (label a) (label b) -- | Parse a file by name out of the multipart message file :: - Applicative m => + (Applicative m) => ByteString -> MultipartParseT backend m (MultipartFile Lazy.ByteString) file fieldName = MultipartParseT $ \mp -> @@ -172,14 +172,14 @@ file fieldName = MultipartParseT $ \mp -> -- | Return all files from the multipart message allFiles :: - Applicative m => + (Applicative m) => MultipartParseT backend m [MultipartFile Lazy.ByteString] allFiles = MultipartParseT $ \mp -> do pure $ Success $ mp.files -- | Ensure there is exactly one file and return it (ignoring the field name) exactlyOneFile :: - Applicative m => + (Applicative m) => MultipartParseT backend m (MultipartFile Lazy.ByteString) exactlyOneFile = MultipartParseT $ \mp -> mp.files |