{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# HLINT ignore "Eta reduce" #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
module Grisette.Internal.Unified.Class.UnifiedSafeSymRotate
( safeSymRotateL,
safeSymRotateR,
UnifiedSafeSymRotate (..),
)
where
import Control.Exception (ArithException)
import Control.Monad.Error.Class (MonadError)
import GHC.TypeLits (KnownNat, type (<=))
import Grisette.Internal.Core.Data.Class.SafeSymRotate (SafeSymRotate)
import qualified Grisette.Internal.Core.Data.Class.SafeSymRotate
import Grisette.Internal.SymPrim.BV (IntN, WordN)
import Grisette.Internal.SymPrim.SomeBV
( SomeBVException,
SomeIntN,
SomeSymIntN,
SomeSymWordN,
SomeWordN,
)
import Grisette.Internal.SymPrim.SymBV (SymIntN, SymWordN)
import Grisette.Internal.Unified.Class.UnifiedSimpleMergeable
( UnifiedBranching (withBaseBranching),
)
import Grisette.Internal.Unified.EvalModeTag
( EvalModeTag (S),
)
import Grisette.Internal.Unified.Util (withMode)
safeSymRotateL ::
forall mode e a m.
( MonadError e m,
UnifiedSafeSymRotate mode e a m
) =>
a ->
a ->
m a
safeSymRotateL :: forall (mode :: EvalModeTag) e a (m :: * -> *).
(MonadError e m, UnifiedSafeSymRotate mode e a m) =>
a -> a -> m a
safeSymRotateL a
a a
b =
forall (mode :: EvalModeTag) e a (m :: * -> *) r.
UnifiedSafeSymRotate mode e a m =>
(SafeSymRotate e a m => r) -> r
withBaseSafeSymRotate @mode @e @a @m ((SafeSymRotate e a m => m a) -> m a)
-> (SafeSymRotate e a m => m a) -> m a
forall a b. (a -> b) -> a -> b
$
a -> a -> m a
forall e a (m :: * -> *). SafeSymRotate e a m => a -> a -> m a
Grisette.Internal.Core.Data.Class.SafeSymRotate.safeSymRotateL a
a a
b
{-# INLINE safeSymRotateL #-}
safeSymRotateR ::
forall mode e a m.
( MonadError e m,
UnifiedSafeSymRotate mode e a m
) =>
a ->
a ->
m a
safeSymRotateR :: forall (mode :: EvalModeTag) e a (m :: * -> *).
(MonadError e m, UnifiedSafeSymRotate mode e a m) =>
a -> a -> m a
safeSymRotateR a
a a
b =
forall (mode :: EvalModeTag) e a (m :: * -> *) r.
UnifiedSafeSymRotate mode e a m =>
(SafeSymRotate e a m => r) -> r
withBaseSafeSymRotate @mode @e @a @m ((SafeSymRotate e a m => m a) -> m a)
-> (SafeSymRotate e a m => m a) -> m a
forall a b. (a -> b) -> a -> b
$
a -> a -> m a
forall e a (m :: * -> *). SafeSymRotate e a m => a -> a -> m a
Grisette.Internal.Core.Data.Class.SafeSymRotate.safeSymRotateR a
a a
b
{-# INLINE safeSymRotateR #-}
class UnifiedSafeSymRotate (mode :: EvalModeTag) e a m where
withBaseSafeSymRotate :: ((SafeSymRotate e a m) => r) -> r
instance
{-# INCOHERENT #-}
(UnifiedBranching mode m, SafeSymRotate e a m) =>
UnifiedSafeSymRotate mode e a m
where
withBaseSafeSymRotate :: forall r. (SafeSymRotate e a m => r) -> r
withBaseSafeSymRotate SafeSymRotate e a m => r
r = r
SafeSymRotate e a m => r
r
instance
(MonadError ArithException m, UnifiedBranching mode m, KnownNat n, 1 <= n) =>
UnifiedSafeSymRotate mode ArithException (IntN n) m
where
withBaseSafeSymRotate :: forall r. (SafeSymRotate ArithException (IntN n) m => r) -> r
withBaseSafeSymRotate SafeSymRotate ArithException (IntN n) m => r
r =
forall (mode :: EvalModeTag) r.
DecideEvalMode mode =>
((mode ~ 'C) => r) -> ((mode ~ 'S) => r) -> r
withMode @mode (forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @mode @m r
If (IsConMode mode) (TryMerge m) (SymBranching m) => r
SafeSymRotate ArithException (IntN n) m => r
r) (forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @mode @m r
If (IsConMode mode) (TryMerge m) (SymBranching m) => r
SafeSymRotate ArithException (IntN n) m => r
r)
instance
(MonadError ArithException m, UnifiedBranching 'S m, KnownNat n, 1 <= n) =>
UnifiedSafeSymRotate 'S ArithException (SymIntN n) m
where
withBaseSafeSymRotate :: forall r. (SafeSymRotate ArithException (SymIntN n) m => r) -> r
withBaseSafeSymRotate SafeSymRotate ArithException (SymIntN n) m => r
r = forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @'S @m r
If (IsConMode 'S) (TryMerge m) (SymBranching m) => r
SafeSymRotate ArithException (SymIntN n) m => r
r
instance
(MonadError ArithException m, UnifiedBranching mode m, KnownNat n, 1 <= n) =>
UnifiedSafeSymRotate mode ArithException (WordN n) m
where
withBaseSafeSymRotate :: forall r. (SafeSymRotate ArithException (WordN n) m => r) -> r
withBaseSafeSymRotate SafeSymRotate ArithException (WordN n) m => r
r =
forall (mode :: EvalModeTag) r.
DecideEvalMode mode =>
((mode ~ 'C) => r) -> ((mode ~ 'S) => r) -> r
withMode @mode (forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @mode @m r
If (IsConMode mode) (TryMerge m) (SymBranching m) => r
SafeSymRotate ArithException (WordN n) m => r
r) (forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @mode @m r
If (IsConMode mode) (TryMerge m) (SymBranching m) => r
SafeSymRotate ArithException (WordN n) m => r
r)
instance
(MonadError ArithException m, UnifiedBranching 'S m, KnownNat n, 1 <= n) =>
UnifiedSafeSymRotate 'S ArithException (SymWordN n) m
where
withBaseSafeSymRotate :: forall r. (SafeSymRotate ArithException (SymWordN n) m => r) -> r
withBaseSafeSymRotate SafeSymRotate ArithException (SymWordN n) m => r
r = forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @'S @m r
If (IsConMode 'S) (TryMerge m) (SymBranching m) => r
SafeSymRotate ArithException (SymWordN n) m => r
r
instance
( MonadError (Either SomeBVException ArithException) m,
UnifiedBranching mode m
) =>
UnifiedSafeSymRotate
mode
(Either SomeBVException ArithException)
SomeIntN
m
where
withBaseSafeSymRotate :: forall r.
(SafeSymRotate
(Either SomeBVException ArithException) SomeIntN m =>
r)
-> r
withBaseSafeSymRotate SafeSymRotate (Either SomeBVException ArithException) SomeIntN m =>
r
r =
forall (mode :: EvalModeTag) r.
DecideEvalMode mode =>
((mode ~ 'C) => r) -> ((mode ~ 'S) => r) -> r
withMode @mode (forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @mode @m r
If (IsConMode mode) (TryMerge m) (SymBranching m) => r
SafeSymRotate (Either SomeBVException ArithException) SomeIntN m =>
r
r) (forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @mode @m r
If (IsConMode mode) (TryMerge m) (SymBranching m) => r
SafeSymRotate (Either SomeBVException ArithException) SomeIntN m =>
r
r)
instance
( MonadError (Either SomeBVException ArithException) m,
UnifiedBranching 'S m
) =>
UnifiedSafeSymRotate
'S
(Either SomeBVException ArithException)
SomeSymIntN
m
where
withBaseSafeSymRotate :: forall r.
(SafeSymRotate
(Either SomeBVException ArithException) SomeSymIntN m =>
r)
-> r
withBaseSafeSymRotate SafeSymRotate
(Either SomeBVException ArithException) SomeSymIntN m =>
r
r = forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @'S @m r
If (IsConMode 'S) (TryMerge m) (SymBranching m) => r
SafeSymRotate
(Either SomeBVException ArithException) SomeSymIntN m =>
r
r
instance
( MonadError (Either SomeBVException ArithException) m,
UnifiedBranching mode m
) =>
UnifiedSafeSymRotate
mode
(Either SomeBVException ArithException)
SomeWordN
m
where
withBaseSafeSymRotate :: forall r.
(SafeSymRotate
(Either SomeBVException ArithException) SomeWordN m =>
r)
-> r
withBaseSafeSymRotate SafeSymRotate
(Either SomeBVException ArithException) SomeWordN m =>
r
r =
forall (mode :: EvalModeTag) r.
DecideEvalMode mode =>
((mode ~ 'C) => r) -> ((mode ~ 'S) => r) -> r
withMode @mode (forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @mode @m r
If (IsConMode mode) (TryMerge m) (SymBranching m) => r
SafeSymRotate
(Either SomeBVException ArithException) SomeWordN m =>
r
r) (forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @mode @m r
If (IsConMode mode) (TryMerge m) (SymBranching m) => r
SafeSymRotate
(Either SomeBVException ArithException) SomeWordN m =>
r
r)
instance
( MonadError (Either SomeBVException ArithException) m,
UnifiedBranching 'S m
) =>
UnifiedSafeSymRotate
'S
(Either SomeBVException ArithException)
SomeSymWordN
m
where
withBaseSafeSymRotate :: forall r.
(SafeSymRotate
(Either SomeBVException ArithException) SomeSymWordN m =>
r)
-> r
withBaseSafeSymRotate SafeSymRotate
(Either SomeBVException ArithException) SomeSymWordN m =>
r
r = forall (mode :: EvalModeTag) (m :: * -> *) r.
UnifiedBranching mode m =>
(If (IsConMode mode) (TryMerge m) (SymBranching m) => r) -> r
withBaseBranching @'S @m r
If (IsConMode 'S) (TryMerge m) (SymBranching m) => r
SafeSymRotate
(Either SomeBVException ArithException) SomeSymWordN m =>
r
r