aboutsummaryrefslogtreecommitdiffstats
path: root/src/Data/JLD/Model/NodeObject.hs
blob: d0bb4c5a4e35320deeee41646c194a6871a1e212 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Data.JLD.Model.NodeObject (isNodeObject, isNotNodeObject) where

import Data.JLD.Prelude

import Data.JLD.Model.Keyword (Keyword (..))

import Data.Aeson (Value (..))
import Data.Aeson.Key qualified as K
import Data.Aeson.KeyMap qualified as KM

isNodeObject :: Value -> Bool
isNodeObject (Object o) =
    ( not (KM.member (show KeywordValue) o)
        && not (KM.member (show KeywordList) o)
        && not (KM.member (show KeywordSet) o)
    )
        || (KM.keys o == ([KeywordContext, KeywordGraph] <&> show .> K.fromText))
isNodeObject _ = False

isNotNodeObject :: Value -> Bool
isNotNodeObject = isNodeObject .> not