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