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