aboutsummaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorLia Lenckowski <lialenck@protonmail.com>2023-08-24 14:00:11 +0200
committerLia Lenckowski <lialenck@protonmail.com>2023-08-24 14:00:11 +0200
commit1fedb7f1e73bc56002181775a546e9c2407a8e40 (patch)
tree2955ab53ef02a334935ad67c2c2bc9e46f53643f /src/Main.hs
parent33bc8bfb247f4fcbfc206bdeb9c0e118e961ba59 (diff)
downloadfastbangs-1fedb7f1e73bc56002181775a546e9c2407a8e40.tar
fastbangs-1fedb7f1e73bc56002181775a546e9c2407a8e40.tar.bz2
fastbangs-1fedb7f1e73bc56002181775a546e9c2407a8e40.tar.zst
add toEncoding implementations (~15% encoding speedup)
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 0f0146c..626983c 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -42,7 +42,10 @@ instance ToJSON PendingBang where
Nothing -> []
Just e -> ["email" .= e]
- -- TODO toEncoding. Not sure how much value that holds though
+ toEncoding (PendingBang b u dp em) = pairs $ case em of
+ Nothing -> withoutEmail
+ Just e -> withoutEmail <> "email" .= e
+ where withoutEmail = "bang" .= b <> "url" .= u <> "name" .= dp
instance FromJSON PendingBang where
parseJSON = withObject "PendingBang" $ \ob ->