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