grisette-0.11.0.0: Symbolic evaluation as a library
Copyright(c) Sirui Lu 2024
LicenseBSD-3-Clause (see the LICENSE file)
Maintainersiruilu@cs.washington.edu
StabilityExperimental
PortabilityGHC only
Safe HaskellNone
LanguageHaskell2010

Grisette.Internal.Core.Data.Class.SafeFdiv

Description

 
Synopsis

Documentation

class (MonadError e m, TryMerge m, Mergeable a) => SafeFdiv e a (m :: Type -> Type) where Source #

Safe fractional division with monadic error handling in multi-path execution. These procedures throw an exception when the denominator is zero. The result should be able to handle errors with MonadError.

Minimal complete definition

safeFdiv

Methods

safeFdiv :: a -> a -> m a Source #

Safe fractional division with monadic error handling in multi-path execution.

>>> safeFdiv "a" "b" :: ExceptT ArithException Union SymAlgReal
ExceptT {If (= b 0.0) (Left Ratio has zero denominator) (Right (fdiv a b))}

safeRecip :: a -> m a Source #

Safe fractional reciprocal with monadic error handling in multi-path execution.

>>> safeRecip "a" :: ExceptT ArithException Union SymAlgReal
ExceptT {If (= a 0.0) (Left Ratio has zero denominator) (Right (recip a))}

default safeRecip :: Fractional a => a -> m a Source #

class FdivOr a where Source #

Safe fractional with default values returned on exception.

Methods

fdivOr :: a -> a -> a -> a Source #

Safe / with default values returned on exception.

>>> fdivOr "d" "a" "b" :: SymAlgReal
(ite (= b 0.0) d (fdiv a b))

recipOr :: a -> a -> a Source #

Safe recip with default values returned on exception.

>>> recipOr "d" "a" :: SymAlgReal
(ite (= a 0.0) d (recip a))

fdivOrZero :: (FdivOr a, Num a) => a -> a -> a Source #

Safe / with 0 returned on exception.

recipOrZero :: (FdivOr a, Num a) => a -> a Source #

Safe recip with 0 returned on exception.