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