From 261f1216a116f71768ca1f375533f1c35edc2816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= <mordae@anilinux.org> Date: Sun, 17 Nov 2019 14:50:51 +0100 Subject: [PATCH] Add FromParam () and ToParam () MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Can be used to work with field existence. Signed-off-by: Jan Hamal Dvořák <mordae@anilinux.org> --- lib/Hikaru/Types.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Hikaru/Types.hs b/lib/Hikaru/Types.hs index 5169d2b..ab025cd 100644 --- a/lib/Hikaru/Types.hs +++ b/lib/Hikaru/Types.hs @@ -80,6 +80,9 @@ where instance FromParam Double where fromParam = readMaybe . unpack + instance FromParam () where + fromParam _ = Just () + instance FromParam Bool where fromParam "true" = Just True fromParam "True" = Just True @@ -158,6 +161,9 @@ where instance ToParam Double where toParam = pack . show + instance ToParam () where + toParam _ = "" + instance ToParam Bool where toParam True = "true" toParam False = "false" -- GitLab