From ae9461cbc641de31e4bd35e5b56f7de126e7f9fa Mon Sep 17 00:00:00 2001 From: Dominick Gendill Date: Tue, 9 May 2017 17:43:52 -0600 Subject: [PATCH] Added strMapToYaml instance --- src/Data/YAML/Foreign/Encode.purs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Data/YAML/Foreign/Encode.purs b/src/Data/YAML/Foreign/Encode.purs index 8ff7400..0472ac4 100644 --- a/src/Data/YAML/Foreign/Encode.purs +++ b/src/Data/YAML/Foreign/Encode.purs @@ -1,10 +1,12 @@ module Data.YAML.Foreign.Encode where import Data.Map as M +import Data.StrMap as StrMap import Data.Array (toUnfoldable) import Data.Function.Uncurried (Fn4, runFn4) import Data.List (List) import Data.Maybe (Maybe, maybe) +import Data.StrMap (StrMap, insert) import Data.Tuple (Tuple(..), fst, snd) import Prelude (class Eq, class Show, map, show, ($), (<>), (==), (<<<)) import Unsafe.Coerce (unsafeCoerce) @@ -44,6 +46,9 @@ instance eqYValue :: Eq YValue where class ToYAML a where toYAML :: a -> YValue +instance strMapToYAML :: (ToYAML a) => ToYAML (StrMap a) where + toYAML strMap = YObject $ StrMap.fold (\acc key value -> M.insert key (toYAML value) acc) M.empty strMap + instance booleanToYAML :: ToYAML Boolean where toYAML = YBoolean