never executed always true always false
    1 {-# LANGUAGE DeriveGeneric, DeriveDataTypeable, DeriveFunctor, DeriveTraversable, DeriveFoldable #-}
    2 
    3 module Conjure.Language.Expression.Op.LexLeq 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 OpLexLeq x = OpLexLeq x x
   15     deriving (Eq, Ord, Show, Data, Functor, Traversable, Foldable, Typeable, Generic)
   16 
   17 instance Serialize x => Serialize (OpLexLeq x)
   18 instance Hashable  x => Hashable  (OpLexLeq x)
   19 instance ToJSON    x => ToJSON    (OpLexLeq x) where toJSON = genericToJSON jsonOptions
   20 instance FromJSON  x => FromJSON  (OpLexLeq x) where parseJSON = genericParseJSON jsonOptions
   21 
   22 instance BinaryOperator (OpLexLeq x) where
   23     opLexeme _ = L_LexLeq
   24 
   25 instance (TypeOf x, Pretty x) => TypeOf (OpLexLeq x) where
   26     typeOf p@(OpLexLeq a b) = do
   27         tyA <- typeOf a
   28         tyB <- typeOf b
   29         if typesUnify [tyA, tyB]
   30             then return TypeBool
   31             else raiseTypeError $ vcat [ pretty p
   32                                        , "LHS has type:" <+> pretty tyA
   33                                        , "RHS has type:" <+> pretty tyB
   34                                        ]
   35 
   36 instance SimplifyOp OpLexLeq x where
   37     simplifyOp _ = na "simplifyOp{OpLexLeq}"
   38 
   39 instance Pretty x => Pretty (OpLexLeq x) where
   40     prettyPrec prec op@(OpLexLeq a b) = prettyPrecBinOp prec [op] a b
   41 
   42 instance VarSymBreakingDescription x => VarSymBreakingDescription (OpLexLeq x) where
   43     varSymBreakingDescription (OpLexLeq a b) = JSON.Object $ KM.fromList
   44         [ ("type", JSON.String "OpLexLeq")
   45         , ("children", JSON.Array $ V.fromList
   46             [ varSymBreakingDescription a
   47             , varSymBreakingDescription b
   48             ])
   49         ]