Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Arith a
- = Arith !a
- | ArithError !SomeException
- arithM :: MonadThrow m => Arith a -> m a
- arithMaybe :: Arith a -> Maybe a
- arithEither :: Arith a -> Either SomeException a
- arithError :: HasCallStack => Arith a -> a
- plusBounded :: (MonadThrow m, Ord a, Num a, Bounded a) => a -> a -> m a
- minusBounded :: (MonadThrow m, Ord a, Num a, Bounded a) => a -> a -> m a
- timesBounded :: (MonadThrow m, Integral a, Bounded a) => a -> a -> m a
- absBounded :: (MonadThrow m, Num p, Ord p) => p -> m p
- fromIntegerBounded :: forall m a. (MonadThrow m, Integral a, Bounded a) => Integer -> m a
- divBounded :: (MonadThrow m, Integral a, Bounded a) => a -> a -> m a
- quotBounded :: (MonadThrow m, Integral a, Bounded a) => a -> a -> m a
- quotRemBounded :: (MonadThrow m, Integral a, Bounded a) => a -> a -> m (a, a)
Arith Monad
Monad for performing safe computation
Instances
arithM :: MonadThrow m => Arith a -> m a Source #
Convert Arith
computation to any MonadThrow
>>>
import Numeric.Decimal
>>>
:set -XDataKinds
>>>
arithM (1.1 * 123 :: Arith (Decimal RoundDown 3 Int))
135.300>>>
arithM (1.1 - 123 :: Arith (Decimal RoundDown 3 Word))
*** Exception: arithmetic underflow>>>
1.1 - 123 :: Arith (Decimal RoundDown 3 Word)
ArithError arithmetic underflow
Since: 0.2.0
arithEither :: Arith a -> Either SomeException a Source #
arithError :: HasCallStack => Arith a -> a Source #
Bounded
plusBounded :: (MonadThrow m, Ord a, Num a, Bounded a) => a -> a -> m a Source #
minusBounded :: (MonadThrow m, Ord a, Num a, Bounded a) => a -> a -> m a Source #
timesBounded :: (MonadThrow m, Integral a, Bounded a) => a -> a -> m a Source #
Multiply two numbers while checking for Overflow
Since: 0.1.0
absBounded :: (MonadThrow m, Num p, Ord p) => p -> m p Source #
Compute absolute value, while checking for Overflow
Since: 0.2.0
fromIntegerBounded :: forall m a. (MonadThrow m, Integral a, Bounded a) => Integer -> m a Source #
divBounded :: (MonadThrow m, Integral a, Bounded a) => a -> a -> m a Source #
Divide two numbers while checking for Overflow
and DivideByZero
Since: 0.1.0
quotBounded :: (MonadThrow m, Integral a, Bounded a) => a -> a -> m a Source #
Find quotient of two numbers while checking for Overflow
and DivideByZero
Since: 0.1.0
quotRemBounded :: (MonadThrow m, Integral a, Bounded a) => a -> a -> m (a, a) Source #
Find quotient an remainder of two numbers while checking for Overflow
and
DivideByZero
Since: 0.1.0