{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wall -Werror -fno-warn-orphans #-}
module Data.SBV.Either (
sLeft, sRight, liftEither, SEither, sEither, sEither_, sEithers
, either
, bimap, first, second
, isLeft, isRight, fromLeft, fromRight
) where
import Prelude hiding (either)
import qualified Prelude
import Data.SBV.Client
import Data.SBV.Core.Data
import Data.SBV.Core.Model (ite, OrdSymbolic(..))
#ifdef DOCTEST
#endif
mkSymbolic [''Either]
sEither :: (SymVal a, SymVal b) => String -> Symbolic (SEither a b)
sEither :: forall a b.
(SymVal a, SymVal b) =>
String -> Symbolic (SEither a b)
sEither = String -> SymbolicT IO (SBV (Either a b))
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
forall (m :: * -> *).
MonadSymbolic m =>
String -> m (SBV (Either a b))
free
sEither_ :: (SymVal a, SymVal b) => Symbolic (SEither a b)
sEither_ :: forall a b. (SymVal a, SymVal b) => Symbolic (SEither a b)
sEither_ = SymbolicT IO (SBV (Either a b))
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
forall (m :: * -> *). MonadSymbolic m => m (SBV (Either a b))
free_
sEithers :: (SymVal a, SymVal b) => [String] -> Symbolic [SEither a b]
sEithers :: forall a b.
(SymVal a, SymVal b) =>
[String] -> Symbolic [SEither a b]
sEithers = [String] -> SymbolicT IO [SBV (Either a b)]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
forall (m :: * -> *).
MonadSymbolic m =>
[String] -> m [SBV (Either a b)]
symbolics
liftEither :: (SymVal a, SymVal b) => Either (SBV a) (SBV b) -> SEither a b
liftEither :: forall a b.
(SymVal a, SymVal b) =>
Either (SBV a) (SBV b) -> SEither a b
liftEither = (SBV a -> SEither a b)
-> (SBV b -> SEither a b) -> Either (SBV a) (SBV b) -> SEither a b
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Prelude.either SBV a -> SEither a b
forall a b. (SymVal a, SymVal b) => SBV a -> SBV (Either a b)
sLeft SBV b -> SEither a b
forall a b. (SymVal a, SymVal b) => SBV b -> SBV (Either a b)
sRight
either :: forall a b c. (SymVal a, SymVal b, SymVal c)
=> (SBV a -> SBV c)
-> (SBV b -> SBV c)
-> SEither a b
-> SBV c
either :: forall a b c.
(SymVal a, SymVal b, SymVal c) =>
(SBV a -> SBV c) -> (SBV b -> SBV c) -> SEither a b -> SBV c
either SBV a -> SBV c
brA SBV b -> SBV c
brB SEither a b
sab = SBool -> SBV c -> SBV c -> SBV c
forall a. Mergeable a => SBool -> a -> a -> a
ite (SEither a b -> SBool
forall a b. (SymVal a, SymVal b) => SBV (Either a b) -> SBool
isLeft SEither a b
sab) (SBV a -> SBV c
brA (SEither a b -> SBV a
forall a b. (SymVal a, SymVal b) => SBV (Either a b) -> SBV a
fromLeft SEither a b
sab)) (SBV b -> SBV c
brB (SEither a b -> SBV b
forall a b. (SymVal a, SymVal b) => SBV (Either a b) -> SBV b
fromRight SEither a b
sab))
bimap :: forall a b c d. (SymVal a, SymVal b, SymVal c, SymVal d)
=> (SBV a -> SBV b)
-> (SBV c -> SBV d)
-> SEither a c
-> SEither b d
bimap :: forall a b c d.
(SymVal a, SymVal b, SymVal c, SymVal d) =>
(SBV a -> SBV b) -> (SBV c -> SBV d) -> SEither a c -> SEither b d
bimap SBV a -> SBV b
brA SBV c -> SBV d
brC = (SBV a -> SBV (Either b d))
-> (SBV c -> SBV (Either b d)) -> SEither a c -> SBV (Either b d)
forall a b c.
(SymVal a, SymVal b, SymVal c) =>
(SBV a -> SBV c) -> (SBV b -> SBV c) -> SEither a b -> SBV c
either (SBV b -> SBV (Either b d)
forall a b. (SymVal a, SymVal b) => SBV a -> SBV (Either a b)
sLeft (SBV b -> SBV (Either b d))
-> (SBV a -> SBV b) -> SBV a -> SBV (Either b d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SBV a -> SBV b
brA) (SBV d -> SBV (Either b d)
forall a b. (SymVal a, SymVal b) => SBV b -> SBV (Either a b)
sRight (SBV d -> SBV (Either b d))
-> (SBV c -> SBV d) -> SBV c -> SBV (Either b d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SBV c -> SBV d
brC)
first :: (SymVal a, SymVal b, SymVal c) => (SBV a -> SBV b) -> SEither a c -> SEither b c
first :: forall a b c.
(SymVal a, SymVal b, SymVal c) =>
(SBV a -> SBV b) -> SEither a c -> SEither b c
first SBV a -> SBV b
f = (SBV a -> SBV b) -> (SBV c -> SBV c) -> SEither a c -> SEither b c
forall a b c d.
(SymVal a, SymVal b, SymVal c, SymVal d) =>
(SBV a -> SBV b) -> (SBV c -> SBV d) -> SEither a c -> SEither b d
bimap SBV a -> SBV b
f SBV c -> SBV c
forall a. a -> a
id
second :: (SymVal a, SymVal b, SymVal c) => (SBV b -> SBV c) -> SEither a b -> SEither a c
second :: forall a b c.
(SymVal a, SymVal b, SymVal c) =>
(SBV b -> SBV c) -> SEither a b -> SEither a c
second = (SBV a -> SBV a) -> (SBV b -> SBV c) -> SEither a b -> SEither a c
forall a b c d.
(SymVal a, SymVal b, SymVal c, SymVal d) =>
(SBV a -> SBV b) -> (SBV c -> SBV d) -> SEither a c -> SEither b d
bimap SBV a -> SBV a
forall a. a -> a
id
fromLeft :: forall a b. (SymVal a, SymVal b) => SEither a b -> SBV a
fromLeft :: forall a b. (SymVal a, SymVal b) => SBV (Either a b) -> SBV a
fromLeft = SBV (Either a b) -> SBV a
forall a b. (SymVal a, SymVal b) => SBV (Either a b) -> SBV a
getLeft_1
fromRight :: forall a b. (SymVal a, SymVal b) => SEither a b -> SBV b
fromRight :: forall a b. (SymVal a, SymVal b) => SBV (Either a b) -> SBV b
fromRight = SBV (Either a b) -> SBV b
forall a b. (SymVal a, SymVal b) => SBV (Either a b) -> SBV b
getRight_1
instance (OrdSymbolic (SBV a), OrdSymbolic (SBV b), SymVal a, SymVal b) => OrdSymbolic (SBV (Either a b)) where
SBV (Either a b)
eab .< :: SBV (Either a b) -> SBV (Either a b) -> SBool
.< SBV (Either a b)
ecd = (SBV a -> SBool) -> (SBV b -> SBool) -> SBV (Either a b) -> SBool
forall a b c.
(SymVal a, SymVal b, SymVal c) =>
(SBV a -> SBV c) -> (SBV b -> SBV c) -> SEither a b -> SBV c
either (\SBV a
a -> (SBV a -> SBool) -> (SBV b -> SBool) -> SBV (Either a b) -> SBool
forall a b c.
(SymVal a, SymVal b, SymVal c) =>
(SBV a -> SBV c) -> (SBV b -> SBV c) -> SEither a b -> SBV c
either (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<) (SBool -> SBV b -> SBool
forall a b. a -> b -> a
const SBool
sTrue) SBV (Either a b)
ecd)
(\SBV b
b -> (SBV a -> SBool) -> (SBV b -> SBool) -> SBV (Either a b) -> SBool
forall a b c.
(SymVal a, SymVal b, SymVal c) =>
(SBV a -> SBV c) -> (SBV b -> SBV c) -> SEither a b -> SBV c
either (SBool -> SBV a -> SBool
forall a b. a -> b -> a
const SBool
sFalse) (SBV b
b SBV b -> SBV b -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<) SBV (Either a b)
ecd)
SBV (Either a b)
eab