From b2e4264e7849f322cbb2bb592b15d2ea7aec9149 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 28 Jul 2016 23:14:50 +0200 Subject: Switch from monoid to foldable container --- events/src/Main.hs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'events/src/Main.hs') diff --git a/events/src/Main.hs b/events/src/Main.hs index 0454f22..a4ffa5a 100644 --- a/events/src/Main.hs +++ b/events/src/Main.hs @@ -11,18 +11,23 @@ import Control.Lens import Control.Monad import Control.Monad.Trans import Data.Aeson.Lens -import Data.Aeson import Debug.Trace +import Data.Maybe (isJust) + import qualified ListT +import qualified Events.Types.NDT as NDT main :: IO () --- main = test $ [ Nop --- , Override [("blub", String "Haha!")] --- , Occurs True --- , Occurs False --- ] --- where --- test = CBS.putStr . Yaml.encode <=< evaluate . interpret -main = undefined +main = test $ do + n <- lift $ NDT.fromFoldable ([1..] :: [Integer]) + -- objOccurs .= (n <= 5) + objOccurs .= (n >= 2) + objPayload ?= [ ("num", Yaml.Number $ fromIntegral n) + ] + where + test = CBS.putStr . Yaml.encode <=< evaluate predicate + predicate :: Monad m => Maybe Yaml.Object -> m Bool + predicate Nothing = return True + predicate (Just obj) = return . maybe False (<= 5) . traceShowId $ obj ^. at "num" . asDouble -- cgit v1.2.3