{-# OPTIONS_GHC -Wall -Werror #-}
module Data.SBV.Rational (
(.%)
) where
import qualified Data.Ratio as R
import Data.SBV.Core.Data
import Data.SBV.Core.Model ()
infixl 7 .%
(.%) :: SInteger -> SInteger -> SRational
SInteger
top .% :: SInteger -> SInteger -> SRational
.% SInteger
bot
| Just Integer
t <- forall a. SymVal a => SBV a -> Maybe a
unliteral SInteger
top
, Just Integer
b <- forall a. SymVal a => SBV a -> Maybe a
unliteral SInteger
bot
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ Integer
t forall a. Integral a => a -> a -> Ratio a
R.% Integer
b
| Bool
True
= forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KRational forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a. (State -> IO a) -> Cached a
cache State -> IO SV
res
where res :: State -> IO SV
res State
st = do SV
t <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SInteger
top
SV
b <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SInteger
bot
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
KRational forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp Op
RationalConstructor [SV
t, SV
b]