never executed always true always false
1 {-# LANGUAGE DeriveGeneric, DeriveDataTypeable, DeriveFunctor, DeriveTraversable, DeriveFoldable #-}
2
3 module Conjure.Language.Expression.Op.Leq 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 OpLeq x = OpLeq x x
15 deriving (Eq, Ord, Show, Data, Functor, Traversable, Foldable, Typeable, Generic)
16
17 instance Serialize x => Serialize (OpLeq x)
18 instance Hashable x => Hashable (OpLeq x)
19 instance ToJSON x => ToJSON (OpLeq x) where toJSON = genericToJSON jsonOptions
20 instance FromJSON x => FromJSON (OpLeq x) where parseJSON = genericParseJSON jsonOptions
21
22 instance BinaryOperator (OpLeq x) where
23 opLexeme _ = L_Leq
24
25 instance (TypeOf x, Pretty x) => TypeOf (OpLeq x) where
26 typeOf p@(OpLeq a b) = sameToSameToBool p a b [] $ \case
27 TypeBool -> True
28 TypeInt{} | ?typeCheckerMode == RelaxedIntegerTags -> True
29 TypeInt TagInt -> True
30 TypeInt TagEnum{} -> True
31 _ -> False
32
33 instance SimplifyOp OpLeq x where
34 simplifyOp _ = na "simplifyOp{OpLeq}"
35
36 instance Pretty x => Pretty (OpLeq x) where
37 prettyPrec prec op@(OpLeq a b) = prettyPrecBinOp prec [op] a b
38
39 instance VarSymBreakingDescription x => VarSymBreakingDescription (OpLeq x) where
40 varSymBreakingDescription (OpLeq a b) = JSON.Object $ KM.fromList
41 [ ("type", JSON.String "OpLeq")
42 , ("children", JSON.Array $ V.fromList
43 [ varSymBreakingDescription a
44 , varSymBreakingDescription b
45 ])
46 ]