never executed always true always false
1 {-# LANGUAGE DeriveGeneric, DeriveDataTypeable, DeriveFunctor, DeriveTraversable, DeriveFoldable #-}
2
3 module Conjure.Language.Expression.Op.PowerSet where
4
5 import Conjure.Prelude
6 import Conjure.Language.Expression.Op.Internal.Common
7
8 import qualified Data.Aeson as JSON -- aeson
9 import qualified Data.Aeson.KeyMap as KM
10
11 import qualified Data.Vector as V -- vector
12
13
14 data OpPowerSet x = OpPowerSet x
15 deriving (Eq, Ord, Show, Data, Functor, Traversable, Foldable, Typeable, Generic)
16
17 instance Serialize x => Serialize (OpPowerSet x)
18 instance Hashable x => Hashable (OpPowerSet x)
19 instance ToJSON x => ToJSON (OpPowerSet x) where toJSON = genericToJSON jsonOptions
20 instance FromJSON x => FromJSON (OpPowerSet x) where parseJSON = genericParseJSON jsonOptions
21 instance (TypeOf x, Pretty x) => TypeOf (OpPowerSet x) where
22 typeOf p@(OpPowerSet x) = do
23 tx <- typeOf x
24 case tx of
25 TypeSet i -> return (TypeSet (TypeSet i))
26 _ -> raiseTypeError p
27
28 instance SimplifyOp OpPowerSet x where
29 simplifyOp _ = na "simplifyOp{OpPowerSet}"
30
31 instance Pretty x => Pretty (OpPowerSet x) where
32 prettyPrec _ (OpPowerSet a) = "powerSet" <> prParens (pretty a)
33
34 instance VarSymBreakingDescription x => VarSymBreakingDescription (OpPowerSet x) where
35 varSymBreakingDescription (OpPowerSet a) = JSON.Object $ KM.fromList
36 [ ("type", JSON.String "OpPowerSet")
37 , ("children", JSON.Array $ V.fromList
38 [ varSymBreakingDescription a
39 ])
40 ]