blob: 410ea1ddfb1c140a3903ded7dea6e1fca24de45a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLists #-}
import Events.Types
import Events.Spec
import Events.Eval
import qualified Data.Yaml as Yaml
import qualified Data.ByteString.Char8 as CBS
import Control.Lens
import Control.Monad
import Control.Monad.Trans
import Data.Aeson.Lens
import Debug.Trace
import Data.Maybe (isJust)
import qualified ListT
import qualified Events.Types.NDT as NDT
main :: IO ()
main = test $ do
n <- Eval . lift $ NDT.fromFoldable ([1..] :: [Integer])
lower <- filter (maybe False (< fromIntegral n) <$> view (at "num" . asDouble)) <$> view ctxEvents
-- objOccurs .= (n <= 5)
objOccurs .= (n >= 2)
objPayload ?= [ ("num", Yaml.Number $ fromIntegral n)
, ("count", Yaml.Number . fromIntegral . length $ lower)
]
where
test = CBS.putStr . Yaml.encode <=< evaluate predicate
predicate :: Monad m => Maybe Yaml.Object -> m Bool
predicate = ordPredicate $ maybe LT (`compare` 5) . view (at "num" . asDouble)
-- predicate Nothing = return True
-- predicate (Just obj) = return . maybe False (<= 5) . traceShowId $ obj ^. at "num" . asDouble
|