never executed always true always false
1 {-# LANGUAGE DeriveGeneric, DeriveDataTypeable, DeriveFunctor, DeriveTraversable, DeriveFoldable #-}
2
3 module Conjure.Language.Expression.Op.DontCare 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 OpDontCare x = OpDontCare x
15 deriving (Eq, Ord, Show, Data, Functor, Traversable, Foldable, Typeable, Generic)
16
17 instance Serialize x => Serialize (OpDontCare x)
18 instance Hashable x => Hashable (OpDontCare x)
19 instance ToJSON x => ToJSON (OpDontCare x) where toJSON = genericToJSON jsonOptions
20 instance FromJSON x => FromJSON (OpDontCare x) where parseJSON = genericParseJSON jsonOptions
21
22 instance TypeOf (OpDontCare x) where
23 typeOf (OpDontCare _) = return TypeBool
24
25 instance SimplifyOp OpDontCare x where
26 simplifyOp _ = na "simplifyOp{OpDontCare}"
27
28 instance Pretty x => Pretty (OpDontCare x) where
29 prettyPrec _ (OpDontCare a) = "dontCare" <> prParens (pretty a)
30
31 instance VarSymBreakingDescription x => VarSymBreakingDescription (OpDontCare x) where
32 varSymBreakingDescription (OpDontCare a) = JSON.Object $ KM.fromList
33 [ ("type", JSON.String "OpDontCare")
34 , ("children", JSON.Array $ V.fromList
35 [ varSymBreakingDescription a
36 ])
37 ]