{-# LANGUAGE CPP #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Grisette.Core.Data.Class.ExtractSymbolics
(
ExtractSymbolics (..),
)
where
import Control.Monad.Except
import Control.Monad.Identity
import Control.Monad.Trans.Maybe
import qualified Control.Monad.Writer.Lazy as WriterLazy
import qualified Control.Monad.Writer.Strict as WriterStrict
import qualified Data.ByteString as B
import Data.Functor.Sum
import Data.Int
import Data.Word
import Generics.Deriving
import {-# SOURCE #-} Grisette.IR.SymPrim.Data.Prim.Model
class a where
:: a -> SymbolSet
instance (Generic a, ExtractSymbolics' (Rep a)) => ExtractSymbolics (Default a) where
extractSymbolics :: Default a -> SymbolSet
extractSymbolics = forall (a :: * -> *) c. ExtractSymbolics' a => a c -> SymbolSet
extractSymbolics' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a x. Generic a => a -> Rep a x
from forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Default a -> a
unDefault
class a where
:: a c -> SymbolSet
instance ExtractSymbolics' U1 where
extractSymbolics' :: forall c. U1 c -> SymbolSet
extractSymbolics' U1 c
_ = forall a. Monoid a => a
mempty
instance (ExtractSymbolics c) => ExtractSymbolics' (K1 i c) where
extractSymbolics' :: forall c. K1 i c c -> SymbolSet
extractSymbolics' = forall a. ExtractSymbolics a => a -> SymbolSet
extractSymbolics forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k i c (p :: k). K1 i c p -> c
unK1
instance (ExtractSymbolics' a) => ExtractSymbolics' (M1 i c a) where
extractSymbolics' :: forall c. M1 i c a c -> SymbolSet
extractSymbolics' = forall (a :: * -> *) c. ExtractSymbolics' a => a c -> SymbolSet
extractSymbolics' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k i (c :: Meta) (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
instance
(ExtractSymbolics' a, ExtractSymbolics' b) =>
ExtractSymbolics' (a :+: b)
where
extractSymbolics' :: forall c. (:+:) a b c -> SymbolSet
extractSymbolics' (L1 a c
l) = forall (a :: * -> *) c. ExtractSymbolics' a => a c -> SymbolSet
extractSymbolics' a c
l
extractSymbolics' (R1 b c
r) = forall (a :: * -> *) c. ExtractSymbolics' a => a c -> SymbolSet
extractSymbolics' b c
r
instance
(ExtractSymbolics' a, ExtractSymbolics' b) =>
ExtractSymbolics' (a :*: b)
where
extractSymbolics' :: forall c. (:*:) a b c -> SymbolSet
extractSymbolics' (a c
l :*: b c
r) = forall (a :: * -> *) c. ExtractSymbolics' a => a c -> SymbolSet
extractSymbolics' a c
l forall a. Semigroup a => a -> a -> a
<> forall (a :: * -> *) c. ExtractSymbolics' a => a c -> SymbolSet
extractSymbolics' b c
r
#define CONCRETE_EXTRACT_SYMBOLICS(type) \
instance ExtractSymbolics type where \
extractSymbolics _ = mempty
#if 1
CONCRETE_EXTRACT_SYMBOLICS(Bool)
CONCRETE_EXTRACT_SYMBOLICS(Integer)
CONCRETE_EXTRACT_SYMBOLICS(Char)
CONCRETE_EXTRACT_SYMBOLICS(Int)
CONCRETE_EXTRACT_SYMBOLICS(Int8)
CONCRETE_EXTRACT_SYMBOLICS(Int16)
CONCRETE_EXTRACT_SYMBOLICS(Int32)
CONCRETE_EXTRACT_SYMBOLICS(Int64)
CONCRETE_EXTRACT_SYMBOLICS(Word)
CONCRETE_EXTRACT_SYMBOLICS(Word8)
CONCRETE_EXTRACT_SYMBOLICS(Word16)
CONCRETE_EXTRACT_SYMBOLICS(Word32)
CONCRETE_EXTRACT_SYMBOLICS(Word64)
CONCRETE_EXTRACT_SYMBOLICS(B.ByteString)
#endif
instance ExtractSymbolics () where
extractSymbolics :: () -> SymbolSet
extractSymbolics ()
_ = forall a. Monoid a => a
mempty
deriving via
(Default (Either a b))
instance
(ExtractSymbolics a, ExtractSymbolics b) =>
ExtractSymbolics (Either a b)
deriving via
(Default (Maybe a))
instance
(ExtractSymbolics a) => ExtractSymbolics (Maybe a)
deriving via
(Default [a])
instance
(ExtractSymbolics a) => ExtractSymbolics [a]
deriving via
(Default (a, b))
instance
(ExtractSymbolics a, ExtractSymbolics b) =>
ExtractSymbolics (a, b)
deriving via
(Default (a, b, c))
instance
(ExtractSymbolics a, ExtractSymbolics b, ExtractSymbolics c) =>
ExtractSymbolics (a, b, c)
instance (ExtractSymbolics (m (Maybe a))) => ExtractSymbolics (MaybeT m a) where
extractSymbolics :: MaybeT m a -> SymbolSet
extractSymbolics (MaybeT m (Maybe a)
v) = forall a. ExtractSymbolics a => a -> SymbolSet
extractSymbolics m (Maybe a)
v
instance
(ExtractSymbolics (m (Either e a))) =>
ExtractSymbolics (ExceptT e m a)
where
extractSymbolics :: ExceptT e m a -> SymbolSet
extractSymbolics (ExceptT m (Either e a)
v) = forall a. ExtractSymbolics a => a -> SymbolSet
extractSymbolics m (Either e a)
v
deriving via
(Default (Sum f g a))
instance
(ExtractSymbolics (f a), ExtractSymbolics (g a)) =>
ExtractSymbolics (Sum f g a)
instance
(ExtractSymbolics (m (a, s))) =>
ExtractSymbolics (WriterLazy.WriterT s m a)
where
extractSymbolics :: WriterT s m a -> SymbolSet
extractSymbolics (WriterLazy.WriterT m (a, s)
f) = forall a. ExtractSymbolics a => a -> SymbolSet
extractSymbolics m (a, s)
f
instance
(ExtractSymbolics (m (a, s))) =>
ExtractSymbolics (WriterStrict.WriterT s m a)
where
extractSymbolics :: WriterT s m a -> SymbolSet
extractSymbolics (WriterStrict.WriterT m (a, s)
f) = forall a. ExtractSymbolics a => a -> SymbolSet
extractSymbolics m (a, s)
f
instance (ExtractSymbolics a) => ExtractSymbolics (Identity a) where
extractSymbolics :: Identity a -> SymbolSet
extractSymbolics (Identity a
a) = forall a. ExtractSymbolics a => a -> SymbolSet
extractSymbolics a
a
instance (ExtractSymbolics (m a)) => ExtractSymbolics (IdentityT m a) where
extractSymbolics :: IdentityT m a -> SymbolSet
extractSymbolics (IdentityT m a
a) = forall a. ExtractSymbolics a => a -> SymbolSet
extractSymbolics m a
a