From 082433e3069e799f69075acbf6cf940fe9f492a0 Mon Sep 17 00:00:00 2001 From: Ilya Portnov Date: Sun, 9 May 2010 19:38:07 +0600 Subject: [PATCH] Add instance IsYamlObject Bool --- Network/YAML/Instances.hs | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/Network/YAML/Instances.hs b/Network/YAML/Instances.hs index 2ad71d2..2b654b3 100644 --- a/Network/YAML/Instances.hs +++ b/Network/YAML/Instances.hs @@ -120,6 +120,26 @@ instance ConvertSuccess Integer YamlObject where instance IsYamlObject Integer where +instance IsYamlScalar Bool where + toYamlScalar True = stringScalar "True" + toYamlScalar False = stringScalar "False" + + fromYamlScalar x = + case fromYamlScalar x :: String of + "True" -> True + _ -> False + +instance Default Bool where + def = False + +instance ConvertSuccess Bool YamlObject where + convertSuccess x = Scalar $ toYamlScalar x + +instance ConvertSuccess YamlObject Bool where + convertSuccess x = fromMaybe def $ getScalar x + +instance IsYamlObject Bool where + instance ConvertSuccess YamlObject BS.ByteString where convertSuccess x = fromMaybe def $ getScalar x -- 1.7.2.3